@viwoapp/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.
@@ -0,0 +1,1199 @@
1
+ import { PublicKey, Connection, Commitment, Transaction, VersionedTransaction, TransactionInstruction } from '@solana/web3.js';
2
+ import { BN, AnchorProvider } from '@coral-xyz/anchor';
3
+ export { BN } from '@coral-xyz/anchor';
4
+
5
+ declare const PROGRAM_IDS: {
6
+ vcoinToken: PublicKey;
7
+ vevcoinToken: PublicKey;
8
+ stakingProtocol: PublicKey;
9
+ transferHook: PublicKey;
10
+ identityProtocol: PublicKey;
11
+ fiveAProtocol: PublicKey;
12
+ contentRegistry: PublicKey;
13
+ governanceProtocol: PublicKey;
14
+ sscreProtocol: PublicKey;
15
+ vilinkProtocol: PublicKey;
16
+ gaslessProtocol: PublicKey;
17
+ };
18
+ declare const SEEDS: {
19
+ vcoinConfig: string;
20
+ vevcoinConfig: string;
21
+ userVevcoin: string;
22
+ stakingPool: string;
23
+ userStake: string;
24
+ governanceConfig: string;
25
+ proposal: string;
26
+ voteRecord: string;
27
+ delegation: string;
28
+ poolConfig: string;
29
+ epoch: string;
30
+ userClaim: string;
31
+ vilinkConfig: string;
32
+ action: string;
33
+ userStats: string;
34
+ dapp: string;
35
+ gaslessConfig: string;
36
+ sessionKey: string;
37
+ userGasless: string;
38
+ feeVault: string;
39
+ identityConfig: string;
40
+ identity: string;
41
+ fiveAConfig: string;
42
+ userScore: string;
43
+ vouch: string;
44
+ registryConfig: string;
45
+ content: string;
46
+ userEnergy: string;
47
+ };
48
+ declare const VCOIN_DECIMALS = 9;
49
+ declare const VEVCOIN_DECIMALS = 9;
50
+ declare const VCOIN_TOTAL_SUPPLY = 1000000000;
51
+ declare const VCOIN_INITIAL_CIRCULATING = 100000000;
52
+ declare const STAKING_TIERS: {
53
+ none: {
54
+ minStake: number;
55
+ feeDiscount: number;
56
+ boost: number;
57
+ minLock: number;
58
+ };
59
+ bronze: {
60
+ minStake: number;
61
+ feeDiscount: number;
62
+ boost: number;
63
+ minLock: number;
64
+ };
65
+ silver: {
66
+ minStake: number;
67
+ feeDiscount: number;
68
+ boost: number;
69
+ minLock: number;
70
+ };
71
+ gold: {
72
+ minStake: number;
73
+ feeDiscount: number;
74
+ boost: number;
75
+ minLock: number;
76
+ };
77
+ platinum: {
78
+ minStake: number;
79
+ feeDiscount: number;
80
+ boost: number;
81
+ minLock: number;
82
+ };
83
+ };
84
+ declare const LOCK_DURATIONS: {
85
+ none: number;
86
+ oneMonth: number;
87
+ threeMonths: number;
88
+ sixMonths: number;
89
+ oneYear: number;
90
+ };
91
+ declare const SSCRE_CONSTANTS: {
92
+ primaryReserves: number;
93
+ secondaryReserves: number;
94
+ epochDuration: number;
95
+ claimWindow: number;
96
+ gaslessFeeBps: number;
97
+ minClaimAmount: number;
98
+ };
99
+ declare const VILINK_CONSTANTS: {
100
+ maxActionExpiry: number;
101
+ minTipAmount: number;
102
+ maxTipAmount: number;
103
+ platformFeeBps: number;
104
+ };
105
+ declare const ACTION_SCOPES: {
106
+ tip: number;
107
+ vouch: number;
108
+ content: number;
109
+ governance: number;
110
+ transfer: number;
111
+ stake: number;
112
+ claim: number;
113
+ follow: number;
114
+ all: number;
115
+ };
116
+ declare const GASLESS_CONSTANTS: {
117
+ sessionDuration: number;
118
+ maxSessionActions: number;
119
+ maxSessionSpend: number;
120
+ defaultSolFee: number;
121
+ vcoinFeeMultiplier: number;
122
+ sscreDeductionBps: number;
123
+ dailySubsidyBudget: number;
124
+ maxSubsidizedPerUser: number;
125
+ };
126
+ declare const FIVE_A_CONSTANTS: {
127
+ maxScore: number;
128
+ scoreWeights: {
129
+ authenticity: number;
130
+ accuracy: number;
131
+ agility: number;
132
+ activity: number;
133
+ approved: number;
134
+ };
135
+ scoreMultipliers: {
136
+ "0-20": number;
137
+ "20-40": number;
138
+ "40-60": number;
139
+ "60-80": number;
140
+ "80-100": number;
141
+ };
142
+ };
143
+ declare const CONTENT_CONSTANTS: {
144
+ maxEnergy: number;
145
+ energyRegenRate: number;
146
+ createCost: number;
147
+ editCost: number;
148
+ deleteCost: number;
149
+ };
150
+ declare const GOVERNANCE_CONSTANTS: {
151
+ minProposalThreshold: number;
152
+ votingDuration: number;
153
+ executionDelay: number;
154
+ vetoWindow: number;
155
+ quorumBps: number;
156
+ };
157
+
158
+ interface ConnectionConfig {
159
+ endpoint: string;
160
+ commitment?: Commitment;
161
+ wsEndpoint?: string;
162
+ }
163
+ interface WalletAdapter {
164
+ publicKey: PublicKey | null;
165
+ signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T>;
166
+ signAllTransactions<T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]>;
167
+ }
168
+ /**
169
+ * Core connection manager for ViWoApp SDK
170
+ */
171
+ declare class ViWoConnection {
172
+ connection: Connection;
173
+ commitment: Commitment;
174
+ constructor(config: ConnectionConfig);
175
+ /**
176
+ * Get current slot
177
+ */
178
+ getSlot(): Promise<number>;
179
+ /**
180
+ * Get current block time
181
+ */
182
+ getBlockTime(): Promise<number | null>;
183
+ /**
184
+ * Check if connection is healthy
185
+ */
186
+ isHealthy(): Promise<boolean>;
187
+ }
188
+ /**
189
+ * PDA utility functions
190
+ */
191
+ declare class PDAs {
192
+ private programIds;
193
+ constructor(programIds?: typeof PROGRAM_IDS);
194
+ getVCoinConfig(): PublicKey;
195
+ getStakingPool(): PublicKey;
196
+ getUserStake(user: PublicKey): PublicKey;
197
+ getGovernanceConfig(): PublicKey;
198
+ getProposal(proposalId: BN): PublicKey;
199
+ getVoteRecord(user: PublicKey, proposal: PublicKey): PublicKey;
200
+ getRewardsPoolConfig(): PublicKey;
201
+ getEpochDistribution(epoch: BN): PublicKey;
202
+ getUserClaim(user: PublicKey): PublicKey;
203
+ getViLinkConfig(): PublicKey;
204
+ getViLinkAction(creator: PublicKey, timestamp: BN): PublicKey;
205
+ getUserActionStats(user: PublicKey): PublicKey;
206
+ getGaslessConfig(): PublicKey;
207
+ getSessionKey(user: PublicKey, sessionPubkey: PublicKey): PublicKey;
208
+ getUserGaslessStats(user: PublicKey): PublicKey;
209
+ getIdentityConfig(): PublicKey;
210
+ getUserIdentity(user: PublicKey): PublicKey;
211
+ getFiveAConfig(): PublicKey;
212
+ getUserScore(user: PublicKey): PublicKey;
213
+ getContentRegistryConfig(): PublicKey;
214
+ getContentRecord(contentId: Uint8Array): PublicKey;
215
+ getUserEnergy(user: PublicKey): PublicKey;
216
+ }
217
+ /**
218
+ * Transaction builder utilities
219
+ */
220
+ declare class TransactionBuilder {
221
+ private instructions;
222
+ add(instruction: TransactionInstruction): this;
223
+ addMany(instructions: TransactionInstruction[]): this;
224
+ build(): Transaction;
225
+ clear(): this;
226
+ get length(): number;
227
+ }
228
+ /**
229
+ * Format utilities
230
+ */
231
+ declare function formatVCoin(amount: BN | number, decimals?: number): string;
232
+ declare function parseVCoin(amount: string | number, decimals?: number): BN;
233
+ /**
234
+ * Time utilities
235
+ */
236
+ declare function getCurrentTimestamp(): number;
237
+ declare function timestampToDate(timestamp: number | BN): Date;
238
+ declare function dateToTimestamp(date: Date): number;
239
+
240
+ interface VCoinConfig {
241
+ authority: PublicKey;
242
+ mint: PublicKey;
243
+ permanentDelegate: PublicKey;
244
+ paused: boolean;
245
+ totalMinted: BN;
246
+ totalBurned: BN;
247
+ }
248
+ declare enum StakingTier {
249
+ None = 0,
250
+ Bronze = 1,
251
+ Silver = 2,
252
+ Gold = 3,
253
+ Platinum = 4
254
+ }
255
+ interface StakingPool {
256
+ authority: PublicKey;
257
+ vcoinMint: PublicKey;
258
+ vevcoinMint: PublicKey;
259
+ totalStaked: BN;
260
+ totalVevcoinMinted: BN;
261
+ paused: boolean;
262
+ }
263
+ interface UserStake {
264
+ user: PublicKey;
265
+ stakedAmount: BN;
266
+ vevcoinBalance: BN;
267
+ tier: StakingTier;
268
+ lockEndTime: BN;
269
+ lastUpdateTime: BN;
270
+ }
271
+ interface StakeParams {
272
+ amount: BN;
273
+ lockDuration: number;
274
+ }
275
+ declare enum ProposalStatus {
276
+ Active = 0,
277
+ Passed = 1,
278
+ Rejected = 2,
279
+ Executed = 3,
280
+ Cancelled = 4
281
+ }
282
+ interface Proposal {
283
+ id: BN;
284
+ proposer: PublicKey;
285
+ title: string;
286
+ descriptionHash: Uint8Array;
287
+ startTime: BN;
288
+ endTime: BN;
289
+ votesFor: BN;
290
+ votesAgainst: BN;
291
+ status: ProposalStatus;
292
+ executed: boolean;
293
+ category: number;
294
+ }
295
+ interface VoteRecord {
296
+ user: PublicKey;
297
+ proposal: PublicKey;
298
+ votePower: BN;
299
+ support: boolean;
300
+ votedAt: BN;
301
+ }
302
+ interface CreateProposalParams {
303
+ title: string;
304
+ description: string;
305
+ category: number;
306
+ durationDays: number;
307
+ }
308
+ interface RewardsPoolConfig {
309
+ authority: PublicKey;
310
+ vcoinMint: PublicKey;
311
+ currentEpoch: BN;
312
+ totalDistributed: BN;
313
+ remainingReserves: BN;
314
+ paused: boolean;
315
+ }
316
+ interface EpochDistribution {
317
+ epoch: BN;
318
+ merkleRoot: Uint8Array;
319
+ totalAllocation: BN;
320
+ totalClaimed: BN;
321
+ claimsCount: BN;
322
+ isFinalized: boolean;
323
+ }
324
+ interface UserClaim {
325
+ user: PublicKey;
326
+ lastClaimedEpoch: BN;
327
+ totalClaimed: BN;
328
+ claimsCount: number;
329
+ }
330
+ interface ClaimRewardsParams {
331
+ epoch: BN;
332
+ amount: BN;
333
+ merkleProof: Uint8Array[];
334
+ }
335
+ declare enum ActionType {
336
+ Tip = 0,
337
+ Vouch = 1,
338
+ Follow = 2,
339
+ Challenge = 3,
340
+ Stake = 4,
341
+ ContentReact = 5,
342
+ Delegate = 6,
343
+ Vote = 7
344
+ }
345
+ interface ViLinkConfig {
346
+ authority: PublicKey;
347
+ vcoinMint: PublicKey;
348
+ treasury: PublicKey;
349
+ enabledActions: number;
350
+ totalActionsCreated: BN;
351
+ totalActionsExecuted: BN;
352
+ totalTipVolume: BN;
353
+ paused: boolean;
354
+ platformFeeBps: number;
355
+ }
356
+ interface ViLinkAction {
357
+ actionId: Uint8Array;
358
+ creator: PublicKey;
359
+ target: PublicKey;
360
+ actionType: ActionType;
361
+ amount: BN;
362
+ expiresAt: BN;
363
+ executed: boolean;
364
+ executionCount: number;
365
+ maxExecutions: number;
366
+ }
367
+ interface CreateActionParams {
368
+ actionType: ActionType;
369
+ target: PublicKey;
370
+ amount?: BN;
371
+ expirySeconds?: number;
372
+ oneTime?: boolean;
373
+ maxExecutions?: number;
374
+ contentId?: Uint8Array;
375
+ metadata?: string;
376
+ }
377
+ declare enum FeeMethod {
378
+ PlatformSubsidized = 0,
379
+ VCoinDeduction = 1,
380
+ SSCREDeduction = 2
381
+ }
382
+ interface GaslessConfig {
383
+ authority: PublicKey;
384
+ feePayer: PublicKey;
385
+ vcoinMint: PublicKey;
386
+ dailySubsidyBudget: BN;
387
+ solFeePerTx: BN;
388
+ vcoinFeeMultiplier: BN;
389
+ totalSubsidizedTx: BN;
390
+ totalVcoinCollected: BN;
391
+ paused: boolean;
392
+ }
393
+ interface SessionKey {
394
+ user: PublicKey;
395
+ sessionPubkey: PublicKey;
396
+ scope: number;
397
+ createdAt: BN;
398
+ expiresAt: BN;
399
+ actionsUsed: number;
400
+ maxActions: number;
401
+ vcoinSpent: BN;
402
+ maxSpend: BN;
403
+ isRevoked: boolean;
404
+ feeMethod: FeeMethod;
405
+ }
406
+ interface CreateSessionParams {
407
+ sessionPubkey: PublicKey;
408
+ scope: number;
409
+ durationSeconds?: number;
410
+ maxActions?: number;
411
+ maxSpend?: BN;
412
+ feeMethod?: FeeMethod;
413
+ }
414
+ interface UserGaslessStats {
415
+ user: PublicKey;
416
+ totalGaslessTx: BN;
417
+ totalSubsidized: BN;
418
+ totalVcoinFees: BN;
419
+ sessionsCreated: number;
420
+ activeSession: PublicKey;
421
+ }
422
+ declare enum VerificationLevel {
423
+ None = 0,// Wallet connected only
424
+ Basic = 1,// Email + phone verified
425
+ KYC = 2,// Identity documents verified
426
+ Full = 3,// KYC + biometric verification
427
+ Enhanced = 4
428
+ }
429
+ interface Identity {
430
+ user: PublicKey;
431
+ didHash: Uint8Array;
432
+ verificationLevel: VerificationLevel;
433
+ createdAt: BN;
434
+ updatedAt: BN;
435
+ }
436
+ interface FiveAScore {
437
+ user: PublicKey;
438
+ authenticity: number;
439
+ accuracy: number;
440
+ agility: number;
441
+ activity: number;
442
+ approved: number;
443
+ compositeScore: number;
444
+ lastUpdated: BN;
445
+ isPrivate: boolean;
446
+ }
447
+ interface VouchRecord {
448
+ voucher: PublicKey;
449
+ vouchee: PublicKey;
450
+ vouchedAt: BN;
451
+ isPositive: boolean;
452
+ outcome: number;
453
+ }
454
+ declare enum ContentState {
455
+ Active = 0,
456
+ Hidden = 1,
457
+ Deleted = 2,
458
+ Flagged = 3
459
+ }
460
+ interface ContentRecord {
461
+ contentId: Uint8Array;
462
+ creator: PublicKey;
463
+ contentHash: Uint8Array;
464
+ state: ContentState;
465
+ createdAt: BN;
466
+ editCount: number;
467
+ tips: BN;
468
+ engagementScore: BN;
469
+ }
470
+ interface UserEnergy {
471
+ user: PublicKey;
472
+ currentEnergy: number;
473
+ maxEnergy: number;
474
+ lastRegenTime: BN;
475
+ tier: number;
476
+ }
477
+
478
+ /**
479
+ * Governance Client for ViWoApp governance operations
480
+ *
481
+ * @example
482
+ * ```typescript
483
+ * const govClient = client.governance;
484
+ *
485
+ * // Create a proposal
486
+ * await govClient.createProposal({
487
+ * title: "Increase staking rewards",
488
+ * description: "Proposal to increase staking APY by 10%",
489
+ * category: 1,
490
+ * durationDays: 7,
491
+ * });
492
+ *
493
+ * // Vote on a proposal
494
+ * await govClient.vote(proposalId, true); // Vote in favor
495
+ * ```
496
+ */
497
+ declare class GovernanceClient {
498
+ private client;
499
+ constructor(client: ViWoClient);
500
+ /**
501
+ * Get governance configuration
502
+ */
503
+ getConfig(): Promise<any | null>;
504
+ /**
505
+ * Get proposal by ID
506
+ */
507
+ getProposal(proposalId: BN): Promise<Proposal | null>;
508
+ /**
509
+ * Get all active proposals
510
+ */
511
+ getActiveProposals(): Promise<Proposal[]>;
512
+ /**
513
+ * Get user's vote record for a proposal
514
+ */
515
+ getVoteRecord(proposalId: BN, user?: PublicKey): Promise<VoteRecord | null>;
516
+ /**
517
+ * Check if user has voted on a proposal
518
+ */
519
+ hasVoted(proposalId: BN, user?: PublicKey): Promise<boolean>;
520
+ /**
521
+ * Calculate user's voting power
522
+ */
523
+ getVotingPower(user?: PublicKey): Promise<BN>;
524
+ /**
525
+ * Get proposal status text
526
+ */
527
+ getStatusText(status: ProposalStatus): string;
528
+ /**
529
+ * Check if proposal can be executed
530
+ */
531
+ canExecute(proposalId: BN): Promise<{
532
+ canExecute: boolean;
533
+ reason?: string;
534
+ }>;
535
+ /**
536
+ * Get proposal progress
537
+ */
538
+ getProposalProgress(proposalId: BN): Promise<{
539
+ votesFor: string;
540
+ votesAgainst: string;
541
+ totalVotes: string;
542
+ forPercentage: number;
543
+ againstPercentage: number;
544
+ quorumReached: boolean;
545
+ timeRemaining: number;
546
+ }>;
547
+ /**
548
+ * Build create proposal transaction
549
+ */
550
+ buildCreateProposalTransaction(params: CreateProposalParams): Promise<Transaction>;
551
+ /**
552
+ * Build vote transaction
553
+ */
554
+ buildVoteTransaction(proposalId: BN, support: boolean): Promise<Transaction>;
555
+ /**
556
+ * Build execute proposal transaction
557
+ */
558
+ buildExecuteTransaction(proposalId: BN): Promise<Transaction>;
559
+ }
560
+
561
+ /**
562
+ * Rewards Client for SSCRE rewards operations
563
+ *
564
+ * @example
565
+ * ```typescript
566
+ * const rewardsClient = client.rewards;
567
+ *
568
+ * // Check claimable rewards
569
+ * const claimable = await rewardsClient.getClaimableRewards();
570
+ * console.log("Claimable:", claimable);
571
+ *
572
+ * // Claim rewards with merkle proof
573
+ * await rewardsClient.claim({
574
+ * epoch: currentEpoch,
575
+ * amount: claimableAmount,
576
+ * merkleProof: proof,
577
+ * });
578
+ * ```
579
+ */
580
+ declare class RewardsClient {
581
+ private client;
582
+ constructor(client: ViWoClient);
583
+ /**
584
+ * Get rewards pool configuration
585
+ */
586
+ getPoolConfig(): Promise<RewardsPoolConfig | null>;
587
+ /**
588
+ * Get epoch distribution details
589
+ */
590
+ getEpochDistribution(epoch: BN): Promise<EpochDistribution | null>;
591
+ /**
592
+ * Get current epoch
593
+ */
594
+ getCurrentEpoch(): Promise<BN>;
595
+ /**
596
+ * Get user claim history
597
+ */
598
+ getUserClaim(user?: PublicKey): Promise<UserClaim | null>;
599
+ /**
600
+ * Check if user has claimed for an epoch
601
+ */
602
+ hasClaimedEpoch(epoch: BN, user?: PublicKey): Promise<boolean>;
603
+ /**
604
+ * Get unclaimed epochs
605
+ */
606
+ getUnclaimedEpochs(user?: PublicKey): Promise<BN[]>;
607
+ /**
608
+ * Get rewards statistics
609
+ */
610
+ getStats(): Promise<{
611
+ currentEpoch: number;
612
+ totalDistributed: string;
613
+ remainingReserves: string;
614
+ reservePercentage: number;
615
+ userTotalClaimed: string | null;
616
+ userClaimsCount: number | null;
617
+ }>;
618
+ /**
619
+ * Calculate gasless fee for claim
620
+ */
621
+ calculateGaslessFee(amount: BN): BN;
622
+ /**
623
+ * Calculate net claim amount after fee
624
+ */
625
+ calculateNetClaim(amount: BN): BN;
626
+ /**
627
+ * Verify merkle proof locally
628
+ */
629
+ verifyMerkleProof(proof: Uint8Array[], root: Uint8Array, leaf: Uint8Array): boolean;
630
+ /**
631
+ * Compute leaf hash from user data
632
+ */
633
+ computeLeaf(user: PublicKey, amount: BN, epoch: BN): Uint8Array;
634
+ private compareBytes;
635
+ private hashBytes;
636
+ /**
637
+ * Build claim rewards transaction
638
+ */
639
+ buildClaimTransaction(params: ClaimRewardsParams): Promise<Transaction>;
640
+ }
641
+
642
+ /**
643
+ * ViLink Client for cross-dApp action deep links
644
+ *
645
+ * @example
646
+ * ```typescript
647
+ * const vilinkClient = client.vilink;
648
+ *
649
+ * // Create a tip action link
650
+ * const action = await vilinkClient.createTipAction({
651
+ * target: recipientPubkey,
652
+ * amount: parseVCoin("10"),
653
+ * });
654
+ *
655
+ * // Generate shareable URI
656
+ * const uri = vilinkClient.generateUri(action.actionId);
657
+ * // => viwo://action/abc123...
658
+ *
659
+ * // Execute action from URI
660
+ * await vilinkClient.executeAction(actionId);
661
+ * ```
662
+ */
663
+ declare class ViLinkClient {
664
+ private client;
665
+ constructor(client: ViWoClient);
666
+ /**
667
+ * Get ViLink configuration
668
+ */
669
+ getConfig(): Promise<ViLinkConfig | null>;
670
+ /**
671
+ * Get action by ID
672
+ */
673
+ getAction(creator: PublicKey, timestamp: BN): Promise<ViLinkAction | null>;
674
+ /**
675
+ * Get user action statistics
676
+ */
677
+ getUserStats(user?: PublicKey): Promise<any | null>;
678
+ /**
679
+ * Get action type name
680
+ */
681
+ getActionTypeName(actionType: ActionType): string;
682
+ /**
683
+ * Check if action type is enabled
684
+ */
685
+ isActionTypeEnabled(actionType: ActionType): Promise<boolean>;
686
+ /**
687
+ * Check if action is valid for execution
688
+ */
689
+ isActionValid(creator: PublicKey, timestamp: BN): Promise<{
690
+ valid: boolean;
691
+ reason?: string;
692
+ }>;
693
+ /**
694
+ * Calculate platform fee for tip
695
+ */
696
+ calculateFee(amount: BN): {
697
+ fee: BN;
698
+ net: BN;
699
+ };
700
+ /**
701
+ * Generate ViLink URI from action ID
702
+ */
703
+ generateUri(actionId: Uint8Array, baseUrl?: string): string;
704
+ /**
705
+ * Parse action ID from URI
706
+ */
707
+ parseUri(uri: string): Uint8Array | null;
708
+ /**
709
+ * Generate QR code data for action
710
+ */
711
+ generateQRData(actionId: Uint8Array): string;
712
+ /**
713
+ * Generate shareable link with metadata
714
+ */
715
+ generateShareableLink(actionId: Uint8Array, metadata?: {
716
+ title?: string;
717
+ amount?: string;
718
+ }): string;
719
+ /**
720
+ * Build create tip action transaction
721
+ */
722
+ buildCreateTipAction(params: {
723
+ target: PublicKey;
724
+ amount: BN;
725
+ expirySeconds?: number;
726
+ oneTime?: boolean;
727
+ metadata?: string;
728
+ }): Promise<Transaction>;
729
+ /**
730
+ * Build create vouch action transaction
731
+ */
732
+ buildCreateVouchAction(params: {
733
+ target: PublicKey;
734
+ expirySeconds?: number;
735
+ }): Promise<Transaction>;
736
+ /**
737
+ * Build create follow action transaction
738
+ */
739
+ buildCreateFollowAction(params: {
740
+ target: PublicKey;
741
+ maxExecutions?: number;
742
+ expirySeconds?: number;
743
+ }): Promise<Transaction>;
744
+ /**
745
+ * Build execute tip action transaction
746
+ */
747
+ buildExecuteTipAction(creator: PublicKey, timestamp: BN): Promise<Transaction>;
748
+ }
749
+
750
+ /**
751
+ * Gasless Client for session key management and gasless transactions
752
+ *
753
+ * @example
754
+ * ```typescript
755
+ * const gaslessClient = client.gasless;
756
+ *
757
+ * // Create a 24-hour session key
758
+ * const sessionKeypair = Keypair.generate();
759
+ * await gaslessClient.createSession({
760
+ * sessionPubkey: sessionKeypair.publicKey,
761
+ * scope: ACTION_SCOPES.tip | ACTION_SCOPES.vouch,
762
+ * feeMethod: FeeMethod.PlatformSubsidized,
763
+ * });
764
+ *
765
+ * // Execute action using session
766
+ * await gaslessClient.executeWithSession(sessionKeypair, tipAction);
767
+ * ```
768
+ */
769
+ declare class GaslessClient {
770
+ private client;
771
+ constructor(client: ViWoClient);
772
+ /**
773
+ * Get gasless configuration
774
+ */
775
+ getConfig(): Promise<GaslessConfig | null>;
776
+ /**
777
+ * Get session key details
778
+ */
779
+ getSessionKey(user: PublicKey, sessionPubkey: PublicKey): Promise<SessionKey | null>;
780
+ /**
781
+ * Get user gasless statistics
782
+ */
783
+ getUserStats(user?: PublicKey): Promise<UserGaslessStats | null>;
784
+ /**
785
+ * Check if session is valid
786
+ */
787
+ isSessionValid(user: PublicKey, sessionPubkey: PublicKey): Promise<{
788
+ valid: boolean;
789
+ reason?: string;
790
+ }>;
791
+ /**
792
+ * Check if action is in session scope
793
+ */
794
+ isActionInScope(session: SessionKey, actionScope: number): boolean;
795
+ /**
796
+ * Get remaining session actions
797
+ */
798
+ getRemainingActions(session: SessionKey): number;
799
+ /**
800
+ * Get remaining session spend
801
+ */
802
+ getRemainingSpend(session: SessionKey): BN;
803
+ /**
804
+ * Get remaining session time
805
+ */
806
+ getRemainingTime(session: SessionKey): number;
807
+ /**
808
+ * Calculate VCoin fee equivalent
809
+ */
810
+ calculateVCoinFee(): Promise<BN>;
811
+ /**
812
+ * Check if user is eligible for subsidized transactions
813
+ */
814
+ isEligibleForSubsidy(user?: PublicKey): Promise<{
815
+ eligible: boolean;
816
+ remainingToday: number;
817
+ reason?: string;
818
+ }>;
819
+ /**
820
+ * Get scope names from scope bitmap
821
+ */
822
+ getScopeNames(scope: number): string[];
823
+ /**
824
+ * Create scope from action names
825
+ */
826
+ createScope(actions: string[]): number;
827
+ /**
828
+ * Build create session key transaction
829
+ */
830
+ buildCreateSessionTransaction(params: CreateSessionParams): Promise<Transaction>;
831
+ /**
832
+ * Build revoke session key transaction
833
+ */
834
+ buildRevokeSessionTransaction(sessionPubkey: PublicKey): Promise<Transaction>;
835
+ /**
836
+ * Build VCoin fee deduction transaction
837
+ */
838
+ buildDeductFeeTransaction(amount?: BN): Promise<Transaction>;
839
+ }
840
+
841
+ /**
842
+ * Identity Client for ViWoApp identity operations
843
+ *
844
+ * @example
845
+ * ```typescript
846
+ * const identityClient = client.identity;
847
+ *
848
+ * // Get user identity
849
+ * const identity = await identityClient.getIdentity(userPubkey);
850
+ * console.log("Verification level:", identityClient.getVerificationLevelName(identity.verificationLevel));
851
+ *
852
+ * // Create identity
853
+ * await identityClient.createIdentity(didHash);
854
+ * ```
855
+ */
856
+ declare class IdentityClient {
857
+ private client;
858
+ constructor(client: ViWoClient);
859
+ /**
860
+ * Get user identity
861
+ */
862
+ getIdentity(user?: PublicKey): Promise<Identity | null>;
863
+ /**
864
+ * Check if user has identity
865
+ */
866
+ hasIdentity(user?: PublicKey): Promise<boolean>;
867
+ /**
868
+ * Get verification level name
869
+ */
870
+ getVerificationLevelName(level: VerificationLevel): string;
871
+ /**
872
+ * Get verification level requirements
873
+ */
874
+ getVerificationRequirements(level: VerificationLevel): string[];
875
+ /**
876
+ * Get verification level benefits
877
+ */
878
+ getVerificationBenefits(level: VerificationLevel): string[];
879
+ /**
880
+ * Build create identity transaction
881
+ */
882
+ buildCreateIdentityTransaction(didHash: Uint8Array): Promise<Transaction>;
883
+ /**
884
+ * Build update DID hash transaction
885
+ */
886
+ buildUpdateDidHashTransaction(newDidHash: Uint8Array): Promise<Transaction>;
887
+ }
888
+
889
+ /**
890
+ * 5A Protocol Client for reputation scoring
891
+ *
892
+ * @example
893
+ * ```typescript
894
+ * const fiveaClient = client.fivea;
895
+ *
896
+ * // Get user's 5A score
897
+ * const score = await fiveaClient.getScore(userPubkey);
898
+ * console.log("Composite score:", score.composite);
899
+ *
900
+ * // Vouch for another user
901
+ * await fiveaClient.vouch(targetPubkey);
902
+ * ```
903
+ */
904
+ declare class FiveAClient {
905
+ private client;
906
+ constructor(client: ViWoClient);
907
+ /**
908
+ * Get user's 5A score
909
+ */
910
+ getScore(user?: PublicKey): Promise<FiveAScore | null>;
911
+ /**
912
+ * Format score as percentage
913
+ */
914
+ formatScore(score: number): string;
915
+ /**
916
+ * Get score tier
917
+ */
918
+ getScoreTier(composite: number): string;
919
+ /**
920
+ * Get reward multiplier for score
921
+ */
922
+ getRewardMultiplier(composite: number): number;
923
+ /**
924
+ * Get score breakdown
925
+ */
926
+ getScoreBreakdown(score: FiveAScore): {
927
+ component: string;
928
+ description: string;
929
+ score: string;
930
+ weight: number;
931
+ contribution: string;
932
+ }[];
933
+ /**
934
+ * Calculate max vouches for score
935
+ */
936
+ getMaxVouches(composite: number): number;
937
+ /**
938
+ * Check if user can vouch for another
939
+ */
940
+ canVouchFor(target: PublicKey): Promise<{
941
+ canVouch: boolean;
942
+ reason?: string;
943
+ }>;
944
+ /**
945
+ * Get score improvement suggestions
946
+ */
947
+ getImprovementSuggestions(score: FiveAScore): string[];
948
+ /**
949
+ * Build vouch transaction
950
+ */
951
+ buildVouchTransaction(target: PublicKey): Promise<Transaction>;
952
+ }
953
+
954
+ /**
955
+ * Content Client for content registry operations
956
+ *
957
+ * @example
958
+ * ```typescript
959
+ * const contentClient = client.content;
960
+ *
961
+ * // Get user's energy
962
+ * const energy = await contentClient.getEnergy();
963
+ * console.log("Current energy:", energy.currentEnergy);
964
+ *
965
+ * // Create content
966
+ * await contentClient.createContent(contentHash);
967
+ * ```
968
+ */
969
+ declare class ContentClient {
970
+ private client;
971
+ constructor(client: ViWoClient);
972
+ /**
973
+ * Get content record
974
+ */
975
+ getContent(contentId: Uint8Array): Promise<ContentRecord | null>;
976
+ /**
977
+ * Get user's energy
978
+ */
979
+ getEnergy(user?: PublicKey): Promise<UserEnergy | null>;
980
+ /**
981
+ * Get content state name
982
+ */
983
+ getStateName(state: ContentState): string;
984
+ /**
985
+ * Calculate regenerated energy
986
+ */
987
+ calculateRegenEnergy(energy: UserEnergy): number;
988
+ /**
989
+ * Get time until next energy
990
+ */
991
+ getTimeUntilNextEnergy(energy: UserEnergy): number;
992
+ /**
993
+ * Get time until full energy
994
+ */
995
+ getTimeUntilFull(energy: UserEnergy): number;
996
+ /**
997
+ * Check if user can create content
998
+ */
999
+ canCreateContent(user?: PublicKey): Promise<{
1000
+ canCreate: boolean;
1001
+ reason?: string;
1002
+ energyNeeded?: number;
1003
+ energyAvailable?: number;
1004
+ }>;
1005
+ /**
1006
+ * Check if user can edit content
1007
+ */
1008
+ canEditContent(contentId: Uint8Array, user?: PublicKey): Promise<{
1009
+ canEdit: boolean;
1010
+ reason?: string;
1011
+ }>;
1012
+ /**
1013
+ * Get content stats
1014
+ */
1015
+ getContentStats(contentId: Uint8Array): Promise<{
1016
+ tips: string;
1017
+ engagementScore: string;
1018
+ editCount: number;
1019
+ state: string;
1020
+ age: number;
1021
+ }>;
1022
+ /**
1023
+ * Build create content transaction
1024
+ */
1025
+ buildCreateContentTransaction(contentHash: Uint8Array): Promise<Transaction>;
1026
+ /**
1027
+ * Build edit content transaction
1028
+ */
1029
+ buildEditContentTransaction(contentId: Uint8Array, newContentHash: Uint8Array): Promise<Transaction>;
1030
+ /**
1031
+ * Build delete content transaction
1032
+ */
1033
+ buildDeleteContentTransaction(contentId: Uint8Array): Promise<Transaction>;
1034
+ }
1035
+
1036
+ interface ViWoClientConfig {
1037
+ connection: ConnectionConfig | Connection;
1038
+ wallet?: WalletAdapter;
1039
+ programIds?: Partial<typeof PROGRAM_IDS>;
1040
+ }
1041
+ /**
1042
+ * Main ViWoApp SDK Client
1043
+ *
1044
+ * Provides unified access to all ViWoApp protocols.
1045
+ *
1046
+ * @example
1047
+ * ```typescript
1048
+ * import { ViWoClient } from "@viwoapp/sdk";
1049
+ *
1050
+ * const client = new ViWoClient({
1051
+ * connection: { endpoint: "https://api.devnet.solana.com" },
1052
+ * wallet: walletAdapter,
1053
+ * });
1054
+ *
1055
+ * // Stake VCoin
1056
+ * await client.staking.stake({ amount: new BN(1000), lockDuration: 30 * 24 * 3600 });
1057
+ *
1058
+ * // Create ViLink tip action
1059
+ * await client.vilink.createTipAction({
1060
+ * target: recipientPubkey,
1061
+ * amount: new BN(10),
1062
+ * });
1063
+ * ```
1064
+ */
1065
+ declare class ViWoClient {
1066
+ connection: ViWoConnection;
1067
+ pdas: PDAs;
1068
+ wallet: WalletAdapter | null;
1069
+ programIds: typeof PROGRAM_IDS;
1070
+ staking: StakingClient;
1071
+ governance: GovernanceClient;
1072
+ rewards: RewardsClient;
1073
+ vilink: ViLinkClient;
1074
+ gasless: GaslessClient;
1075
+ identity: IdentityClient;
1076
+ fivea: FiveAClient;
1077
+ content: ContentClient;
1078
+ constructor(config: ViWoClientConfig);
1079
+ /**
1080
+ * Get the wallet public key
1081
+ */
1082
+ get publicKey(): PublicKey | null;
1083
+ /**
1084
+ * Check if wallet is connected
1085
+ */
1086
+ get isConnected(): boolean;
1087
+ /**
1088
+ * Set wallet adapter
1089
+ */
1090
+ setWallet(wallet: WalletAdapter): void;
1091
+ /**
1092
+ * Get Anchor provider
1093
+ */
1094
+ getProvider(): AnchorProvider | null;
1095
+ /**
1096
+ * Send and confirm transaction
1097
+ */
1098
+ sendTransaction(tx: Transaction): Promise<string>;
1099
+ /**
1100
+ * Get VCoin balance
1101
+ */
1102
+ getVCoinBalance(user?: PublicKey): Promise<BN>;
1103
+ /**
1104
+ * Get veVCoin balance
1105
+ */
1106
+ getVeVCoinBalance(user?: PublicKey): Promise<BN>;
1107
+ /**
1108
+ * Check connection health
1109
+ */
1110
+ healthCheck(): Promise<{
1111
+ connected: boolean;
1112
+ slot: number | null;
1113
+ blockTime: number | null;
1114
+ }>;
1115
+ }
1116
+
1117
+ /**
1118
+ * Staking Client for VCoin staking operations
1119
+ *
1120
+ * @example
1121
+ * ```typescript
1122
+ * const stakingClient = client.staking;
1123
+ *
1124
+ * // Stake 1000 VCoin for 90 days
1125
+ * await stakingClient.stake({
1126
+ * amount: parseVCoin("1000"),
1127
+ * lockDuration: LOCK_DURATIONS.threeMonths,
1128
+ * });
1129
+ *
1130
+ * // Get stake info
1131
+ * const stakeInfo = await stakingClient.getUserStake(walletPubkey);
1132
+ * console.log("Staked:", formatVCoin(stakeInfo.stakedAmount));
1133
+ * ```
1134
+ */
1135
+ declare class StakingClient {
1136
+ private client;
1137
+ constructor(client: ViWoClient);
1138
+ /**
1139
+ * Get staking pool configuration
1140
+ */
1141
+ getPool(): Promise<StakingPool | null>;
1142
+ /**
1143
+ * Get user stake information
1144
+ */
1145
+ getUserStake(user?: PublicKey): Promise<UserStake | null>;
1146
+ /**
1147
+ * Calculate tier based on stake amount
1148
+ */
1149
+ calculateTier(stakeAmount: BN | number): StakingTier;
1150
+ /**
1151
+ * Calculate veVCoin amount for given stake
1152
+ * Formula: ve_vcoin = staked_amount × (lock_duration / 4_years) × tier_boost
1153
+ */
1154
+ calculateVeVCoin(amount: BN, lockDuration: number): BN;
1155
+ /**
1156
+ * Get tier name
1157
+ */
1158
+ getTierName(tier: StakingTier): string;
1159
+ /**
1160
+ * Get tier info
1161
+ */
1162
+ getTierInfo(tier: StakingTier): typeof STAKING_TIERS.none;
1163
+ /**
1164
+ * Check if user can unstake
1165
+ */
1166
+ canUnstake(user?: PublicKey): Promise<{
1167
+ canUnstake: boolean;
1168
+ reason?: string;
1169
+ }>;
1170
+ /**
1171
+ * Get staking statistics
1172
+ */
1173
+ getStats(): Promise<{
1174
+ totalStaked: string;
1175
+ totalVevcoin: string;
1176
+ userStake: string | null;
1177
+ userVevcoin: string | null;
1178
+ userTier: string | null;
1179
+ }>;
1180
+ /**
1181
+ * Build stake instruction
1182
+ * @param params Stake parameters
1183
+ * @returns Transaction to sign and send
1184
+ */
1185
+ buildStakeTransaction(params: StakeParams): Promise<Transaction>;
1186
+ /**
1187
+ * Build unstake instruction
1188
+ * @returns Transaction to sign and send
1189
+ */
1190
+ buildUnstakeTransaction(): Promise<Transaction>;
1191
+ /**
1192
+ * Build extend lock instruction
1193
+ * @param newDuration New lock duration in seconds
1194
+ * @returns Transaction to sign and send
1195
+ */
1196
+ buildExtendLockTransaction(newDuration: number): Promise<Transaction>;
1197
+ }
1198
+
1199
+ export { ACTION_SCOPES, ActionType, CONTENT_CONSTANTS, type ClaimRewardsParams, type ConnectionConfig, ContentClient, type ContentRecord, ContentState, type CreateActionParams, type CreateProposalParams, type CreateSessionParams, type EpochDistribution, FIVE_A_CONSTANTS, FeeMethod, FiveAClient, type FiveAScore, GASLESS_CONSTANTS, GOVERNANCE_CONSTANTS, GaslessClient, type GaslessConfig, GovernanceClient, type Identity, IdentityClient, LOCK_DURATIONS, PDAs, PROGRAM_IDS, type Proposal, ProposalStatus, RewardsClient, type RewardsPoolConfig, SEEDS, SSCRE_CONSTANTS, STAKING_TIERS, type SessionKey, type StakeParams, StakingClient, type StakingPool, StakingTier, TransactionBuilder, type UserClaim, type UserEnergy, type UserGaslessStats, type UserStake, VCOIN_DECIMALS, VCOIN_INITIAL_CIRCULATING, VCOIN_TOTAL_SUPPLY, type VCoinConfig, VEVCOIN_DECIMALS, VILINK_CONSTANTS, VerificationLevel, type ViLinkAction, ViLinkClient, type ViLinkConfig, ViWoClient, ViWoConnection, type VoteRecord, type VouchRecord, type WalletAdapter, dateToTimestamp, formatVCoin, getCurrentTimestamp, parseVCoin, timestampToDate };