@viwoapp/sdk 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,21 @@
1
1
  # @viwoapp/sdk
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@viwoapp/sdk.svg)](https://www.npmjs.com/package/@viwoapp/sdk)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
3
6
  TypeScript SDK for VCoin Protocol Integration on Solana.
4
7
 
8
+ **Version:** 0.1.1 (Security Update)
9
+
10
+ ## What's New in v0.1.1
11
+
12
+ - Added security types for Phase 1-4 audit fixes
13
+ - New types: `SlashRequest`, `DecryptionShare`, `PendingScoreUpdate`
14
+ - All config types now support two-step authority transfer
15
+ - Added `SECURITY_CONSTANTS` for timelocks and limits
16
+ - Added `VALID_URI_PREFIXES` for proposal URI validation
17
+ - New PDA seeds: `slashRequest`, `decryptionShare`, `pendingScore`
18
+
5
19
  ## Installation
6
20
 
7
21
  ```bash
@@ -229,7 +243,18 @@ import {
229
243
  FIVE_A_CONSTANTS,
230
244
  GOVERNANCE_CONSTANTS,
231
245
  CONTENT_CONSTANTS,
246
+ // Security constants (v0.1.1)
247
+ SECURITY_CONSTANTS,
248
+ VALID_URI_PREFIXES,
249
+ MERKLE_CONSTANTS,
232
250
  } from "@viwoapp/sdk";
251
+
252
+ // Security constants
253
+ SECURITY_CONSTANTS.authorityTransferTimelock; // 24 hours
254
+ SECURITY_CONSTANTS.slashApprovalTimelock; // 48 hours
255
+ SECURITY_CONSTANTS.maxFeeSlippageBps; // 500 (5%)
256
+ SECURITY_CONSTANTS.oracleConsensusRequired; // 3-of-N
257
+ SECURITY_CONSTANTS.circuitBreakerCooldown; // 6 hours
233
258
  ```
234
259
 
235
260
  ## Types
@@ -246,6 +271,10 @@ import type {
246
271
  Proposal,
247
272
  VoteRecord,
248
273
  ProposalStatus,
274
+ GovernanceConfig,
275
+ Delegation,
276
+ PrivateVotingConfig,
277
+ DecryptionShare, // v0.1.1: ZK voting
249
278
 
250
279
  // Rewards
251
280
  RewardsPoolConfig,
@@ -267,16 +296,26 @@ import type {
267
296
 
268
297
  // Identity
269
298
  Identity,
299
+ IdentityConfig,
270
300
  VerificationLevel,
271
301
 
272
302
  // 5A
273
303
  FiveAScore,
304
+ FiveAConfig,
274
305
  VouchRecord,
306
+ PendingScoreUpdate, // v0.1.1: Oracle consensus
275
307
 
276
308
  // Content
277
309
  ContentRecord,
310
+ RegistryConfig,
278
311
  UserEnergy,
279
312
  ContentState,
313
+
314
+ // Security (v0.1.1)
315
+ PendingAuthorityFields, // Two-step authority transfer
316
+ SlashRequest, // Governance slashing
317
+ SlashStatus,
318
+ HookConfig, // Transfer hook config
280
319
  } from "@viwoapp/sdk";
281
320
  ```
282
321
 
package/dist/index.d.mts CHANGED
@@ -44,6 +44,9 @@ declare const SEEDS: {
44
44
  registryConfig: string;
45
45
  content: string;
46
46
  userEnergy: string;
47
+ slashRequest: string;
48
+ decryptionShare: string;
49
+ pendingScore: string;
47
50
  };
48
51
  declare const VCOIN_DECIMALS = 9;
49
52
  declare const VEVCOIN_DECIMALS = 9;
@@ -95,12 +98,15 @@ declare const SSCRE_CONSTANTS: {
95
98
  claimWindow: number;
96
99
  gaslessFeeBps: number;
97
100
  minClaimAmount: number;
101
+ circuitBreakerCooldown: number;
98
102
  };
99
103
  declare const VILINK_CONSTANTS: {
100
104
  maxActionExpiry: number;
101
105
  minTipAmount: number;
102
106
  maxTipAmount: number;
103
107
  platformFeeBps: number;
108
+ maxPlatformFeeBps: number;
109
+ minPlatformFeeBps: number;
104
110
  };
105
111
  declare const ACTION_SCOPES: {
106
112
  tip: number;
@@ -122,6 +128,7 @@ declare const GASLESS_CONSTANTS: {
122
128
  sscreDeductionBps: number;
123
129
  dailySubsidyBudget: number;
124
130
  maxSubsidizedPerUser: number;
131
+ maxSlippageBps: number;
125
132
  };
126
133
  declare const FIVE_A_CONSTANTS: {
127
134
  maxScore: number;
@@ -139,6 +146,9 @@ declare const FIVE_A_CONSTANTS: {
139
146
  "60-80": number;
140
147
  "80-100": number;
141
148
  };
149
+ oracleConsensusRequired: number;
150
+ pendingScoreExpiry: number;
151
+ minScoreUpdateInterval: number;
142
152
  };
143
153
  declare const CONTENT_CONSTANTS: {
144
154
  maxEnergy: number;
@@ -153,7 +163,37 @@ declare const GOVERNANCE_CONSTANTS: {
153
163
  executionDelay: number;
154
164
  vetoWindow: number;
155
165
  quorumBps: number;
166
+ zkVotingEnabled: boolean;
156
167
  };
168
+ declare const SECURITY_CONSTANTS: {
169
+ authorityTransferTimelock: number;
170
+ slashApprovalTimelock: number;
171
+ slashExpiry: number;
172
+ maxFeeSlippageBps: number;
173
+ minScoreUpdateInterval: number;
174
+ circuitBreakerCooldown: number;
175
+ oracleConsensusRequired: number;
176
+ pendingScoreExpiry: number;
177
+ maxPlatformFeeBps: number;
178
+ minPlatformFeeBps: number;
179
+ merkleProofMaxSize: number;
180
+ maxEpochBitmap: number;
181
+ votingPowerVerifiedOnChain: boolean;
182
+ };
183
+ declare const VALID_URI_PREFIXES: readonly ["ipfs://", "https://", "ar://"];
184
+ declare const MAX_URI_LENGTH = 128;
185
+ declare const MERKLE_CONSTANTS: {
186
+ leafDomainPrefix: string;
187
+ };
188
+ /** Maximum Merkle proof size (H-NEW-02) - prevents DoS attacks */
189
+ declare const MERKLE_PROOF_MAX_SIZE = 32;
190
+ /** Maximum supported epoch number with bitmap storage (H-NEW-04) */
191
+ declare const MAX_EPOCH_BITMAP = 1023;
192
+ /**
193
+ * @deprecated The legacy slash_tokens function is disabled (C-NEW-02).
194
+ * Use propose_slash -> approve_slash -> execute_slash flow instead.
195
+ */
196
+ declare const LEGACY_SLASH_DEPRECATED = true;
157
197
 
158
198
  interface ConnectionConfig {
159
199
  endpoint: string;
@@ -237,7 +277,12 @@ declare function getCurrentTimestamp(): number;
237
277
  declare function timestampToDate(timestamp: number | BN): Date;
238
278
  declare function dateToTimestamp(date: Date): number;
239
279
 
240
- interface VCoinConfig {
280
+ /** Two-step authority transfer fields (H-02) */
281
+ interface PendingAuthorityFields {
282
+ pendingAuthority?: PublicKey;
283
+ pendingAuthorityActivatedAt?: BN;
284
+ }
285
+ interface VCoinConfig extends PendingAuthorityFields {
241
286
  authority: PublicKey;
242
287
  mint: PublicKey;
243
288
  permanentDelegate: PublicKey;
@@ -245,6 +290,25 @@ interface VCoinConfig {
245
290
  totalMinted: BN;
246
291
  totalBurned: BN;
247
292
  }
293
+ /** Governance-controlled slashing request (H-01) */
294
+ declare enum SlashStatus {
295
+ Proposed = 0,
296
+ Approved = 1,
297
+ Executed = 2,
298
+ Cancelled = 3
299
+ }
300
+ interface SlashRequest {
301
+ target: PublicKey;
302
+ requestId: BN;
303
+ amount: BN;
304
+ reason: Uint8Array;
305
+ proposer: PublicKey;
306
+ proposedAt: BN;
307
+ approvedAt?: BN;
308
+ executedAt?: BN;
309
+ status: SlashStatus;
310
+ governanceProposal?: PublicKey;
311
+ }
248
312
  declare enum StakingTier {
249
313
  None = 0,
250
314
  Bronze = 1,
@@ -252,13 +316,14 @@ declare enum StakingTier {
252
316
  Gold = 3,
253
317
  Platinum = 4
254
318
  }
255
- interface StakingPool {
319
+ interface StakingPool extends PendingAuthorityFields {
256
320
  authority: PublicKey;
257
321
  vcoinMint: PublicKey;
258
322
  vevcoinMint: PublicKey;
259
323
  totalStaked: BN;
260
324
  totalVevcoinMinted: BN;
261
325
  paused: boolean;
326
+ reentrancyGuard?: boolean;
262
327
  }
263
328
  interface UserStake {
264
329
  user: PublicKey;
@@ -279,6 +344,15 @@ declare enum ProposalStatus {
279
344
  Executed = 3,
280
345
  Cancelled = 4
281
346
  }
347
+ /**
348
+ * Vote choice for governance voting (v2.8.0 C-NEW-01)
349
+ * Voting power params are now read from on-chain state, not passed as parameters
350
+ */
351
+ declare enum VoteChoice {
352
+ Against = 0,
353
+ For = 1,
354
+ Abstain = 2
355
+ }
282
356
  interface Proposal {
283
357
  id: BN;
284
358
  proposer: PublicKey;
@@ -305,13 +379,15 @@ interface CreateProposalParams {
305
379
  category: number;
306
380
  durationDays: number;
307
381
  }
308
- interface RewardsPoolConfig {
382
+ interface RewardsPoolConfig extends PendingAuthorityFields {
309
383
  authority: PublicKey;
310
384
  vcoinMint: PublicKey;
311
385
  currentEpoch: BN;
312
386
  totalDistributed: BN;
313
387
  remainingReserves: BN;
314
388
  paused: boolean;
389
+ circuitBreakerActive?: boolean;
390
+ circuitBreakerTriggeredAt?: BN;
315
391
  }
316
392
  interface EpochDistribution {
317
393
  epoch: BN;
@@ -326,6 +402,9 @@ interface UserClaim {
326
402
  lastClaimedEpoch: BN;
327
403
  totalClaimed: BN;
328
404
  claimsCount: number;
405
+ claimedEpochsBitmap?: BN[];
406
+ claimedEpochsBitmapExt?: BN[];
407
+ highEpochsBitmap?: BN[];
329
408
  }
330
409
  interface ClaimRewardsParams {
331
410
  epoch: BN;
@@ -342,7 +421,7 @@ declare enum ActionType {
342
421
  Delegate = 6,
343
422
  Vote = 7
344
423
  }
345
- interface ViLinkConfig {
424
+ interface ViLinkConfig extends PendingAuthorityFields {
346
425
  authority: PublicKey;
347
426
  vcoinMint: PublicKey;
348
427
  treasury: PublicKey;
@@ -379,7 +458,7 @@ declare enum FeeMethod {
379
458
  VCoinDeduction = 1,
380
459
  SSCREDeduction = 2
381
460
  }
382
- interface GaslessConfig {
461
+ interface GaslessConfig extends PendingAuthorityFields {
383
462
  authority: PublicKey;
384
463
  feePayer: PublicKey;
385
464
  vcoinMint: PublicKey;
@@ -389,6 +468,7 @@ interface GaslessConfig {
389
468
  totalSubsidizedTx: BN;
390
469
  totalVcoinCollected: BN;
391
470
  paused: boolean;
471
+ maxSlippageBps?: number;
392
472
  }
393
473
  interface SessionKey {
394
474
  user: PublicKey;
@@ -474,6 +554,75 @@ interface UserEnergy {
474
554
  lastRegenTime: BN;
475
555
  tier: number;
476
556
  }
557
+ interface RegistryConfig extends PendingAuthorityFields {
558
+ authority: PublicKey;
559
+ paused: boolean;
560
+ totalContent: BN;
561
+ }
562
+ interface IdentityConfig extends PendingAuthorityFields {
563
+ authority: PublicKey;
564
+ paused: boolean;
565
+ totalIdentities: BN;
566
+ }
567
+ interface FiveAConfig extends PendingAuthorityFields {
568
+ authority: PublicKey;
569
+ paused: boolean;
570
+ oracleConsensusRequired: number;
571
+ }
572
+ interface GovernanceConfig extends PendingAuthorityFields {
573
+ authority: PublicKey;
574
+ vevcoinMint: PublicKey;
575
+ paused: boolean;
576
+ proposalCount: BN;
577
+ zkVotingEnabled: boolean;
578
+ }
579
+ /** ZK voting decryption share storage (C-02) */
580
+ interface DecryptionShare {
581
+ proposal: PublicKey;
582
+ committeeIndex: number;
583
+ committeeMember: PublicKey;
584
+ share: Uint8Array;
585
+ submittedAt: BN;
586
+ }
587
+ /** Private voting config with committee tracking (C-02) */
588
+ interface PrivateVotingConfig {
589
+ proposal: PublicKey;
590
+ encryptionPubkey: PublicKey;
591
+ decryptionThreshold: number;
592
+ decryptionCommittee: PublicKey[];
593
+ sharesSubmitted: boolean[];
594
+ revealCompleted: boolean;
595
+ aggregatedFor: BN;
596
+ aggregatedAgainst: BN;
597
+ }
598
+ /** Delegation with expiry (M-07) */
599
+ interface Delegation {
600
+ delegator: PublicKey;
601
+ delegate: PublicKey;
602
+ delegationType: number;
603
+ delegatedAmount: BN;
604
+ expiresAt?: BN;
605
+ revocable: boolean;
606
+ }
607
+ /** Pending score update for oracle consensus */
608
+ interface PendingScoreUpdate {
609
+ user: PublicKey;
610
+ authenticity: number;
611
+ accuracy: number;
612
+ agility: number;
613
+ activity: number;
614
+ approved: number;
615
+ oracleSubmissions: PublicKey[];
616
+ submissionCount: number;
617
+ createdAt: BN;
618
+ expiresAt: BN;
619
+ }
620
+ interface HookConfig extends PendingAuthorityFields {
621
+ authority: PublicKey;
622
+ vcoinMint: PublicKey;
623
+ blockWashTrading: boolean;
624
+ paused: boolean;
625
+ }
477
626
 
478
627
  /**
479
628
  * Governance Client for ViWoApp governance operations
@@ -550,6 +699,13 @@ declare class GovernanceClient {
550
699
  buildCreateProposalTransaction(params: CreateProposalParams): Promise<Transaction>;
551
700
  /**
552
701
  * Build vote transaction
702
+ *
703
+ * @note v2.8.0 (C-NEW-01): Voting power parameters (vevcoin_balance, five_a_score, tier)
704
+ * are now read from on-chain state, not passed as parameters. This prevents vote manipulation.
705
+ * The transaction only needs: proposal_id and choice (VoteChoice enum)
706
+ *
707
+ * @param proposalId - The proposal to vote on
708
+ * @param support - true = For, false = Against (use VoteChoice for more options)
553
709
  */
554
710
  buildVoteTransaction(proposalId: BN, support: boolean): Promise<Transaction>;
555
711
  /**
@@ -1196,4 +1352,4 @@ declare class StakingClient {
1196
1352
  buildExtendLockTransaction(newDuration: number): Promise<Transaction>;
1197
1353
  }
1198
1354
 
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 };
1355
+ export { ACTION_SCOPES, ActionType, CONTENT_CONSTANTS, type ClaimRewardsParams, type ConnectionConfig, ContentClient, type ContentRecord, ContentState, type CreateActionParams, type CreateProposalParams, type CreateSessionParams, type DecryptionShare, type Delegation, type EpochDistribution, FIVE_A_CONSTANTS, FeeMethod, FiveAClient, type FiveAConfig, type FiveAScore, GASLESS_CONSTANTS, GOVERNANCE_CONSTANTS, GaslessClient, type GaslessConfig, GovernanceClient, type GovernanceConfig, type HookConfig, type Identity, IdentityClient, type IdentityConfig, LEGACY_SLASH_DEPRECATED, LOCK_DURATIONS, MAX_EPOCH_BITMAP, MAX_URI_LENGTH, MERKLE_CONSTANTS, MERKLE_PROOF_MAX_SIZE, PDAs, PROGRAM_IDS, type PendingAuthorityFields, type PendingScoreUpdate, type PrivateVotingConfig, type Proposal, ProposalStatus, type RegistryConfig, RewardsClient, type RewardsPoolConfig, SECURITY_CONSTANTS, SEEDS, SSCRE_CONSTANTS, STAKING_TIERS, type SessionKey, type SlashRequest, SlashStatus, type StakeParams, StakingClient, type StakingPool, StakingTier, TransactionBuilder, type UserClaim, type UserEnergy, type UserGaslessStats, type UserStake, VALID_URI_PREFIXES, VCOIN_DECIMALS, VCOIN_INITIAL_CIRCULATING, VCOIN_TOTAL_SUPPLY, type VCoinConfig, VEVCOIN_DECIMALS, VILINK_CONSTANTS, VerificationLevel, type ViLinkAction, ViLinkClient, type ViLinkConfig, ViWoClient, ViWoConnection, VoteChoice, type VoteRecord, type VouchRecord, type WalletAdapter, dateToTimestamp, formatVCoin, getCurrentTimestamp, parseVCoin, timestampToDate };
package/dist/index.d.ts CHANGED
@@ -44,6 +44,9 @@ declare const SEEDS: {
44
44
  registryConfig: string;
45
45
  content: string;
46
46
  userEnergy: string;
47
+ slashRequest: string;
48
+ decryptionShare: string;
49
+ pendingScore: string;
47
50
  };
48
51
  declare const VCOIN_DECIMALS = 9;
49
52
  declare const VEVCOIN_DECIMALS = 9;
@@ -95,12 +98,15 @@ declare const SSCRE_CONSTANTS: {
95
98
  claimWindow: number;
96
99
  gaslessFeeBps: number;
97
100
  minClaimAmount: number;
101
+ circuitBreakerCooldown: number;
98
102
  };
99
103
  declare const VILINK_CONSTANTS: {
100
104
  maxActionExpiry: number;
101
105
  minTipAmount: number;
102
106
  maxTipAmount: number;
103
107
  platformFeeBps: number;
108
+ maxPlatformFeeBps: number;
109
+ minPlatformFeeBps: number;
104
110
  };
105
111
  declare const ACTION_SCOPES: {
106
112
  tip: number;
@@ -122,6 +128,7 @@ declare const GASLESS_CONSTANTS: {
122
128
  sscreDeductionBps: number;
123
129
  dailySubsidyBudget: number;
124
130
  maxSubsidizedPerUser: number;
131
+ maxSlippageBps: number;
125
132
  };
126
133
  declare const FIVE_A_CONSTANTS: {
127
134
  maxScore: number;
@@ -139,6 +146,9 @@ declare const FIVE_A_CONSTANTS: {
139
146
  "60-80": number;
140
147
  "80-100": number;
141
148
  };
149
+ oracleConsensusRequired: number;
150
+ pendingScoreExpiry: number;
151
+ minScoreUpdateInterval: number;
142
152
  };
143
153
  declare const CONTENT_CONSTANTS: {
144
154
  maxEnergy: number;
@@ -153,7 +163,37 @@ declare const GOVERNANCE_CONSTANTS: {
153
163
  executionDelay: number;
154
164
  vetoWindow: number;
155
165
  quorumBps: number;
166
+ zkVotingEnabled: boolean;
156
167
  };
168
+ declare const SECURITY_CONSTANTS: {
169
+ authorityTransferTimelock: number;
170
+ slashApprovalTimelock: number;
171
+ slashExpiry: number;
172
+ maxFeeSlippageBps: number;
173
+ minScoreUpdateInterval: number;
174
+ circuitBreakerCooldown: number;
175
+ oracleConsensusRequired: number;
176
+ pendingScoreExpiry: number;
177
+ maxPlatformFeeBps: number;
178
+ minPlatformFeeBps: number;
179
+ merkleProofMaxSize: number;
180
+ maxEpochBitmap: number;
181
+ votingPowerVerifiedOnChain: boolean;
182
+ };
183
+ declare const VALID_URI_PREFIXES: readonly ["ipfs://", "https://", "ar://"];
184
+ declare const MAX_URI_LENGTH = 128;
185
+ declare const MERKLE_CONSTANTS: {
186
+ leafDomainPrefix: string;
187
+ };
188
+ /** Maximum Merkle proof size (H-NEW-02) - prevents DoS attacks */
189
+ declare const MERKLE_PROOF_MAX_SIZE = 32;
190
+ /** Maximum supported epoch number with bitmap storage (H-NEW-04) */
191
+ declare const MAX_EPOCH_BITMAP = 1023;
192
+ /**
193
+ * @deprecated The legacy slash_tokens function is disabled (C-NEW-02).
194
+ * Use propose_slash -> approve_slash -> execute_slash flow instead.
195
+ */
196
+ declare const LEGACY_SLASH_DEPRECATED = true;
157
197
 
158
198
  interface ConnectionConfig {
159
199
  endpoint: string;
@@ -237,7 +277,12 @@ declare function getCurrentTimestamp(): number;
237
277
  declare function timestampToDate(timestamp: number | BN): Date;
238
278
  declare function dateToTimestamp(date: Date): number;
239
279
 
240
- interface VCoinConfig {
280
+ /** Two-step authority transfer fields (H-02) */
281
+ interface PendingAuthorityFields {
282
+ pendingAuthority?: PublicKey;
283
+ pendingAuthorityActivatedAt?: BN;
284
+ }
285
+ interface VCoinConfig extends PendingAuthorityFields {
241
286
  authority: PublicKey;
242
287
  mint: PublicKey;
243
288
  permanentDelegate: PublicKey;
@@ -245,6 +290,25 @@ interface VCoinConfig {
245
290
  totalMinted: BN;
246
291
  totalBurned: BN;
247
292
  }
293
+ /** Governance-controlled slashing request (H-01) */
294
+ declare enum SlashStatus {
295
+ Proposed = 0,
296
+ Approved = 1,
297
+ Executed = 2,
298
+ Cancelled = 3
299
+ }
300
+ interface SlashRequest {
301
+ target: PublicKey;
302
+ requestId: BN;
303
+ amount: BN;
304
+ reason: Uint8Array;
305
+ proposer: PublicKey;
306
+ proposedAt: BN;
307
+ approvedAt?: BN;
308
+ executedAt?: BN;
309
+ status: SlashStatus;
310
+ governanceProposal?: PublicKey;
311
+ }
248
312
  declare enum StakingTier {
249
313
  None = 0,
250
314
  Bronze = 1,
@@ -252,13 +316,14 @@ declare enum StakingTier {
252
316
  Gold = 3,
253
317
  Platinum = 4
254
318
  }
255
- interface StakingPool {
319
+ interface StakingPool extends PendingAuthorityFields {
256
320
  authority: PublicKey;
257
321
  vcoinMint: PublicKey;
258
322
  vevcoinMint: PublicKey;
259
323
  totalStaked: BN;
260
324
  totalVevcoinMinted: BN;
261
325
  paused: boolean;
326
+ reentrancyGuard?: boolean;
262
327
  }
263
328
  interface UserStake {
264
329
  user: PublicKey;
@@ -279,6 +344,15 @@ declare enum ProposalStatus {
279
344
  Executed = 3,
280
345
  Cancelled = 4
281
346
  }
347
+ /**
348
+ * Vote choice for governance voting (v2.8.0 C-NEW-01)
349
+ * Voting power params are now read from on-chain state, not passed as parameters
350
+ */
351
+ declare enum VoteChoice {
352
+ Against = 0,
353
+ For = 1,
354
+ Abstain = 2
355
+ }
282
356
  interface Proposal {
283
357
  id: BN;
284
358
  proposer: PublicKey;
@@ -305,13 +379,15 @@ interface CreateProposalParams {
305
379
  category: number;
306
380
  durationDays: number;
307
381
  }
308
- interface RewardsPoolConfig {
382
+ interface RewardsPoolConfig extends PendingAuthorityFields {
309
383
  authority: PublicKey;
310
384
  vcoinMint: PublicKey;
311
385
  currentEpoch: BN;
312
386
  totalDistributed: BN;
313
387
  remainingReserves: BN;
314
388
  paused: boolean;
389
+ circuitBreakerActive?: boolean;
390
+ circuitBreakerTriggeredAt?: BN;
315
391
  }
316
392
  interface EpochDistribution {
317
393
  epoch: BN;
@@ -326,6 +402,9 @@ interface UserClaim {
326
402
  lastClaimedEpoch: BN;
327
403
  totalClaimed: BN;
328
404
  claimsCount: number;
405
+ claimedEpochsBitmap?: BN[];
406
+ claimedEpochsBitmapExt?: BN[];
407
+ highEpochsBitmap?: BN[];
329
408
  }
330
409
  interface ClaimRewardsParams {
331
410
  epoch: BN;
@@ -342,7 +421,7 @@ declare enum ActionType {
342
421
  Delegate = 6,
343
422
  Vote = 7
344
423
  }
345
- interface ViLinkConfig {
424
+ interface ViLinkConfig extends PendingAuthorityFields {
346
425
  authority: PublicKey;
347
426
  vcoinMint: PublicKey;
348
427
  treasury: PublicKey;
@@ -379,7 +458,7 @@ declare enum FeeMethod {
379
458
  VCoinDeduction = 1,
380
459
  SSCREDeduction = 2
381
460
  }
382
- interface GaslessConfig {
461
+ interface GaslessConfig extends PendingAuthorityFields {
383
462
  authority: PublicKey;
384
463
  feePayer: PublicKey;
385
464
  vcoinMint: PublicKey;
@@ -389,6 +468,7 @@ interface GaslessConfig {
389
468
  totalSubsidizedTx: BN;
390
469
  totalVcoinCollected: BN;
391
470
  paused: boolean;
471
+ maxSlippageBps?: number;
392
472
  }
393
473
  interface SessionKey {
394
474
  user: PublicKey;
@@ -474,6 +554,75 @@ interface UserEnergy {
474
554
  lastRegenTime: BN;
475
555
  tier: number;
476
556
  }
557
+ interface RegistryConfig extends PendingAuthorityFields {
558
+ authority: PublicKey;
559
+ paused: boolean;
560
+ totalContent: BN;
561
+ }
562
+ interface IdentityConfig extends PendingAuthorityFields {
563
+ authority: PublicKey;
564
+ paused: boolean;
565
+ totalIdentities: BN;
566
+ }
567
+ interface FiveAConfig extends PendingAuthorityFields {
568
+ authority: PublicKey;
569
+ paused: boolean;
570
+ oracleConsensusRequired: number;
571
+ }
572
+ interface GovernanceConfig extends PendingAuthorityFields {
573
+ authority: PublicKey;
574
+ vevcoinMint: PublicKey;
575
+ paused: boolean;
576
+ proposalCount: BN;
577
+ zkVotingEnabled: boolean;
578
+ }
579
+ /** ZK voting decryption share storage (C-02) */
580
+ interface DecryptionShare {
581
+ proposal: PublicKey;
582
+ committeeIndex: number;
583
+ committeeMember: PublicKey;
584
+ share: Uint8Array;
585
+ submittedAt: BN;
586
+ }
587
+ /** Private voting config with committee tracking (C-02) */
588
+ interface PrivateVotingConfig {
589
+ proposal: PublicKey;
590
+ encryptionPubkey: PublicKey;
591
+ decryptionThreshold: number;
592
+ decryptionCommittee: PublicKey[];
593
+ sharesSubmitted: boolean[];
594
+ revealCompleted: boolean;
595
+ aggregatedFor: BN;
596
+ aggregatedAgainst: BN;
597
+ }
598
+ /** Delegation with expiry (M-07) */
599
+ interface Delegation {
600
+ delegator: PublicKey;
601
+ delegate: PublicKey;
602
+ delegationType: number;
603
+ delegatedAmount: BN;
604
+ expiresAt?: BN;
605
+ revocable: boolean;
606
+ }
607
+ /** Pending score update for oracle consensus */
608
+ interface PendingScoreUpdate {
609
+ user: PublicKey;
610
+ authenticity: number;
611
+ accuracy: number;
612
+ agility: number;
613
+ activity: number;
614
+ approved: number;
615
+ oracleSubmissions: PublicKey[];
616
+ submissionCount: number;
617
+ createdAt: BN;
618
+ expiresAt: BN;
619
+ }
620
+ interface HookConfig extends PendingAuthorityFields {
621
+ authority: PublicKey;
622
+ vcoinMint: PublicKey;
623
+ blockWashTrading: boolean;
624
+ paused: boolean;
625
+ }
477
626
 
478
627
  /**
479
628
  * Governance Client for ViWoApp governance operations
@@ -550,6 +699,13 @@ declare class GovernanceClient {
550
699
  buildCreateProposalTransaction(params: CreateProposalParams): Promise<Transaction>;
551
700
  /**
552
701
  * Build vote transaction
702
+ *
703
+ * @note v2.8.0 (C-NEW-01): Voting power parameters (vevcoin_balance, five_a_score, tier)
704
+ * are now read from on-chain state, not passed as parameters. This prevents vote manipulation.
705
+ * The transaction only needs: proposal_id and choice (VoteChoice enum)
706
+ *
707
+ * @param proposalId - The proposal to vote on
708
+ * @param support - true = For, false = Against (use VoteChoice for more options)
553
709
  */
554
710
  buildVoteTransaction(proposalId: BN, support: boolean): Promise<Transaction>;
555
711
  /**
@@ -1196,4 +1352,4 @@ declare class StakingClient {
1196
1352
  buildExtendLockTransaction(newDuration: number): Promise<Transaction>;
1197
1353
  }
1198
1354
 
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 };
1355
+ export { ACTION_SCOPES, ActionType, CONTENT_CONSTANTS, type ClaimRewardsParams, type ConnectionConfig, ContentClient, type ContentRecord, ContentState, type CreateActionParams, type CreateProposalParams, type CreateSessionParams, type DecryptionShare, type Delegation, type EpochDistribution, FIVE_A_CONSTANTS, FeeMethod, FiveAClient, type FiveAConfig, type FiveAScore, GASLESS_CONSTANTS, GOVERNANCE_CONSTANTS, GaslessClient, type GaslessConfig, GovernanceClient, type GovernanceConfig, type HookConfig, type Identity, IdentityClient, type IdentityConfig, LEGACY_SLASH_DEPRECATED, LOCK_DURATIONS, MAX_EPOCH_BITMAP, MAX_URI_LENGTH, MERKLE_CONSTANTS, MERKLE_PROOF_MAX_SIZE, PDAs, PROGRAM_IDS, type PendingAuthorityFields, type PendingScoreUpdate, type PrivateVotingConfig, type Proposal, ProposalStatus, type RegistryConfig, RewardsClient, type RewardsPoolConfig, SECURITY_CONSTANTS, SEEDS, SSCRE_CONSTANTS, STAKING_TIERS, type SessionKey, type SlashRequest, SlashStatus, type StakeParams, StakingClient, type StakingPool, StakingTier, TransactionBuilder, type UserClaim, type UserEnergy, type UserGaslessStats, type UserStake, VALID_URI_PREFIXES, VCOIN_DECIMALS, VCOIN_INITIAL_CIRCULATING, VCOIN_TOTAL_SUPPLY, type VCoinConfig, VEVCOIN_DECIMALS, VILINK_CONSTANTS, VerificationLevel, type ViLinkAction, ViLinkClient, type ViLinkConfig, ViWoClient, ViWoConnection, VoteChoice, type VoteRecord, type VouchRecord, type WalletAdapter, dateToTimestamp, formatVCoin, getCurrentTimestamp, parseVCoin, timestampToDate };
package/dist/index.js CHANGED
@@ -34,17 +34,25 @@ __export(index_exports, {
34
34
  GaslessClient: () => GaslessClient,
35
35
  GovernanceClient: () => GovernanceClient,
36
36
  IdentityClient: () => IdentityClient,
37
+ LEGACY_SLASH_DEPRECATED: () => LEGACY_SLASH_DEPRECATED,
37
38
  LOCK_DURATIONS: () => LOCK_DURATIONS,
39
+ MAX_EPOCH_BITMAP: () => MAX_EPOCH_BITMAP,
40
+ MAX_URI_LENGTH: () => MAX_URI_LENGTH,
41
+ MERKLE_CONSTANTS: () => MERKLE_CONSTANTS,
42
+ MERKLE_PROOF_MAX_SIZE: () => MERKLE_PROOF_MAX_SIZE,
38
43
  PDAs: () => PDAs,
39
44
  PROGRAM_IDS: () => PROGRAM_IDS,
40
45
  ProposalStatus: () => ProposalStatus,
41
46
  RewardsClient: () => RewardsClient,
47
+ SECURITY_CONSTANTS: () => SECURITY_CONSTANTS,
42
48
  SEEDS: () => SEEDS,
43
49
  SSCRE_CONSTANTS: () => SSCRE_CONSTANTS,
44
50
  STAKING_TIERS: () => STAKING_TIERS,
51
+ SlashStatus: () => SlashStatus,
45
52
  StakingClient: () => StakingClient,
46
53
  StakingTier: () => StakingTier,
47
54
  TransactionBuilder: () => TransactionBuilder,
55
+ VALID_URI_PREFIXES: () => VALID_URI_PREFIXES,
48
56
  VCOIN_DECIMALS: () => VCOIN_DECIMALS,
49
57
  VCOIN_INITIAL_CIRCULATING: () => VCOIN_INITIAL_CIRCULATING,
50
58
  VCOIN_TOTAL_SUPPLY: () => VCOIN_TOTAL_SUPPLY,
@@ -54,6 +62,7 @@ __export(index_exports, {
54
62
  ViLinkClient: () => ViLinkClient,
55
63
  ViWoClient: () => ViWoClient,
56
64
  ViWoConnection: () => ViWoConnection,
65
+ VoteChoice: () => VoteChoice,
57
66
  dateToTimestamp: () => dateToTimestamp,
58
67
  formatVCoin: () => formatVCoin,
59
68
  getCurrentTimestamp: () => getCurrentTimestamp,
@@ -119,7 +128,14 @@ var SEEDS = {
119
128
  // Content
120
129
  registryConfig: "registry-config",
121
130
  content: "content",
122
- userEnergy: "user-energy"
131
+ userEnergy: "user-energy",
132
+ // Security (Phase 2-4)
133
+ slashRequest: "slash-request",
134
+ // H-01: Governance slashing
135
+ decryptionShare: "decryption-share",
136
+ // C-02: ZK voting shares
137
+ pendingScore: "pending-score"
138
+ // H-05: Oracle consensus
123
139
  };
124
140
  var VCOIN_DECIMALS = 9;
125
141
  var VEVCOIN_DECIMALS = 9;
@@ -150,8 +166,10 @@ var SSCRE_CONSTANTS = {
150
166
  // 90 days
151
167
  gaslessFeeBps: 100,
152
168
  // 1%
153
- minClaimAmount: 1
169
+ minClaimAmount: 1,
154
170
  // 1 VCoin
171
+ circuitBreakerCooldown: 21600
172
+ // M-05: 6 hours before reset
155
173
  };
156
174
  var VILINK_CONSTANTS = {
157
175
  maxActionExpiry: 7 * 24 * 3600,
@@ -160,8 +178,12 @@ var VILINK_CONSTANTS = {
160
178
  // 0.1 VCoin
161
179
  maxTipAmount: 1e4,
162
180
  // 10,000 VCoin
163
- platformFeeBps: 250
181
+ platformFeeBps: 250,
164
182
  // 2.5%
183
+ maxPlatformFeeBps: 1e3,
184
+ // M-02: 10% max
185
+ minPlatformFeeBps: 10
186
+ // M-02: 0.1% min
165
187
  };
166
188
  var ACTION_SCOPES = {
167
189
  tip: 1 << 0,
@@ -187,7 +209,9 @@ var GASLESS_CONSTANTS = {
187
209
  // 1%
188
210
  dailySubsidyBudget: 10,
189
211
  // 10 SOL
190
- maxSubsidizedPerUser: 50
212
+ maxSubsidizedPerUser: 50,
213
+ maxSlippageBps: 500
214
+ // L-03: 5% max slippage for fee conversion
191
215
  };
192
216
  var FIVE_A_CONSTANTS = {
193
217
  maxScore: 1e4,
@@ -210,7 +234,15 @@ var FIVE_A_CONSTANTS = {
210
234
  "40-60": 0.7,
211
235
  "60-80": 1,
212
236
  "80-100": 1.2
213
- }
237
+ },
238
+ // H-05: Oracle consensus
239
+ oracleConsensusRequired: 3,
240
+ // 3-of-N oracles must agree
241
+ pendingScoreExpiry: 3600,
242
+ // 1 hour
243
+ // L-07: Rate limiting
244
+ minScoreUpdateInterval: 3600
245
+ // 1 hour between updates for same user
214
246
  };
215
247
  var CONTENT_CONSTANTS = {
216
248
  maxEnergy: 100,
@@ -229,9 +261,56 @@ var GOVERNANCE_CONSTANTS = {
229
261
  // 2 days
230
262
  vetoWindow: 24 * 3600,
231
263
  // 1 day
232
- quorumBps: 400
264
+ quorumBps: 400,
233
265
  // 4%
266
+ zkVotingEnabled: false
267
+ // C-01: Disabled until proper ZK infrastructure
268
+ };
269
+ var SECURITY_CONSTANTS = {
270
+ // H-02: Two-step authority transfer
271
+ authorityTransferTimelock: 24 * 3600,
272
+ // 24 hours
273
+ // H-01: Governance-controlled slashing
274
+ slashApprovalTimelock: 48 * 3600,
275
+ // 48 hours
276
+ slashExpiry: 7 * 24 * 3600,
277
+ // 7 days
278
+ // L-03: Slippage protection for gasless fees
279
+ maxFeeSlippageBps: 500,
280
+ // 5% max slippage
281
+ // L-07: Oracle rate limiting
282
+ minScoreUpdateInterval: 3600,
283
+ // 1 hour between updates for same user
284
+ // M-05: Circuit breaker cooldown
285
+ circuitBreakerCooldown: 21600,
286
+ // 6 hours (6 * 3600)
287
+ // H-05: Oracle consensus
288
+ oracleConsensusRequired: 3,
289
+ // 3-of-N oracles must agree
290
+ pendingScoreExpiry: 3600,
291
+ // 1 hour
292
+ // M-02: Platform fee bounds (ViLink)
293
+ maxPlatformFeeBps: 1e3,
294
+ // 10% max
295
+ minPlatformFeeBps: 10,
296
+ // 0.1% min
297
+ // v2.8.0 Phase 5 additions
298
+ merkleProofMaxSize: 32,
299
+ // H-NEW-02: Max proof levels (supports 4B+ users)
300
+ maxEpochBitmap: 1023,
301
+ // H-NEW-04: Max epoch with bitmap storage (85+ years)
302
+ votingPowerVerifiedOnChain: true
303
+ // C-NEW-01: Params read from chain, not passed
304
+ };
305
+ var VALID_URI_PREFIXES = ["ipfs://", "https://", "ar://"];
306
+ var MAX_URI_LENGTH = 128;
307
+ var MERKLE_CONSTANTS = {
308
+ leafDomainPrefix: "SSCRE_CLAIM_V1"
309
+ // Domain separation for merkle leaves
234
310
  };
311
+ var MERKLE_PROOF_MAX_SIZE = 32;
312
+ var MAX_EPOCH_BITMAP = 1023;
313
+ var LEGACY_SLASH_DEPRECATED = true;
235
314
 
236
315
  // src/core/index.ts
237
316
  var ViWoConnection = class {
@@ -500,6 +579,13 @@ function dateToTimestamp(date) {
500
579
  }
501
580
 
502
581
  // src/types.ts
582
+ var SlashStatus = /* @__PURE__ */ ((SlashStatus2) => {
583
+ SlashStatus2[SlashStatus2["Proposed"] = 0] = "Proposed";
584
+ SlashStatus2[SlashStatus2["Approved"] = 1] = "Approved";
585
+ SlashStatus2[SlashStatus2["Executed"] = 2] = "Executed";
586
+ SlashStatus2[SlashStatus2["Cancelled"] = 3] = "Cancelled";
587
+ return SlashStatus2;
588
+ })(SlashStatus || {});
503
589
  var StakingTier = /* @__PURE__ */ ((StakingTier2) => {
504
590
  StakingTier2[StakingTier2["None"] = 0] = "None";
505
591
  StakingTier2[StakingTier2["Bronze"] = 1] = "Bronze";
@@ -516,6 +602,12 @@ var ProposalStatus = /* @__PURE__ */ ((ProposalStatus2) => {
516
602
  ProposalStatus2[ProposalStatus2["Cancelled"] = 4] = "Cancelled";
517
603
  return ProposalStatus2;
518
604
  })(ProposalStatus || {});
605
+ var VoteChoice = /* @__PURE__ */ ((VoteChoice2) => {
606
+ VoteChoice2[VoteChoice2["Against"] = 0] = "Against";
607
+ VoteChoice2[VoteChoice2["For"] = 1] = "For";
608
+ VoteChoice2[VoteChoice2["Abstain"] = 2] = "Abstain";
609
+ return VoteChoice2;
610
+ })(VoteChoice || {});
519
611
  var ActionType = /* @__PURE__ */ ((ActionType2) => {
520
612
  ActionType2[ActionType2["Tip"] = 0] = "Tip";
521
613
  ActionType2[ActionType2["Vouch"] = 1] = "Vouch";
@@ -916,6 +1008,13 @@ var GovernanceClient = class {
916
1008
  }
917
1009
  /**
918
1010
  * Build vote transaction
1011
+ *
1012
+ * @note v2.8.0 (C-NEW-01): Voting power parameters (vevcoin_balance, five_a_score, tier)
1013
+ * are now read from on-chain state, not passed as parameters. This prevents vote manipulation.
1014
+ * The transaction only needs: proposal_id and choice (VoteChoice enum)
1015
+ *
1016
+ * @param proposalId - The proposal to vote on
1017
+ * @param support - true = For, false = Against (use VoteChoice for more options)
919
1018
  */
920
1019
  async buildVoteTransaction(proposalId, support) {
921
1020
  if (!this.client.publicKey) {
@@ -926,6 +1025,7 @@ var GovernanceClient = class {
926
1025
  throw new Error("Already voted on this proposal");
927
1026
  }
928
1027
  const tx = new import_web34.Transaction();
1028
+ const choice = support ? 1 /* For */ : 0 /* Against */;
929
1029
  return tx;
930
1030
  }
931
1031
  /**
@@ -2318,17 +2418,25 @@ var ViWoClient = class {
2318
2418
  GaslessClient,
2319
2419
  GovernanceClient,
2320
2420
  IdentityClient,
2421
+ LEGACY_SLASH_DEPRECATED,
2321
2422
  LOCK_DURATIONS,
2423
+ MAX_EPOCH_BITMAP,
2424
+ MAX_URI_LENGTH,
2425
+ MERKLE_CONSTANTS,
2426
+ MERKLE_PROOF_MAX_SIZE,
2322
2427
  PDAs,
2323
2428
  PROGRAM_IDS,
2324
2429
  ProposalStatus,
2325
2430
  RewardsClient,
2431
+ SECURITY_CONSTANTS,
2326
2432
  SEEDS,
2327
2433
  SSCRE_CONSTANTS,
2328
2434
  STAKING_TIERS,
2435
+ SlashStatus,
2329
2436
  StakingClient,
2330
2437
  StakingTier,
2331
2438
  TransactionBuilder,
2439
+ VALID_URI_PREFIXES,
2332
2440
  VCOIN_DECIMALS,
2333
2441
  VCOIN_INITIAL_CIRCULATING,
2334
2442
  VCOIN_TOTAL_SUPPLY,
@@ -2338,6 +2446,7 @@ var ViWoClient = class {
2338
2446
  ViLinkClient,
2339
2447
  ViWoClient,
2340
2448
  ViWoConnection,
2449
+ VoteChoice,
2341
2450
  dateToTimestamp,
2342
2451
  formatVCoin,
2343
2452
  getCurrentTimestamp,
package/dist/index.mjs CHANGED
@@ -59,7 +59,14 @@ var SEEDS = {
59
59
  // Content
60
60
  registryConfig: "registry-config",
61
61
  content: "content",
62
- userEnergy: "user-energy"
62
+ userEnergy: "user-energy",
63
+ // Security (Phase 2-4)
64
+ slashRequest: "slash-request",
65
+ // H-01: Governance slashing
66
+ decryptionShare: "decryption-share",
67
+ // C-02: ZK voting shares
68
+ pendingScore: "pending-score"
69
+ // H-05: Oracle consensus
63
70
  };
64
71
  var VCOIN_DECIMALS = 9;
65
72
  var VEVCOIN_DECIMALS = 9;
@@ -90,8 +97,10 @@ var SSCRE_CONSTANTS = {
90
97
  // 90 days
91
98
  gaslessFeeBps: 100,
92
99
  // 1%
93
- minClaimAmount: 1
100
+ minClaimAmount: 1,
94
101
  // 1 VCoin
102
+ circuitBreakerCooldown: 21600
103
+ // M-05: 6 hours before reset
95
104
  };
96
105
  var VILINK_CONSTANTS = {
97
106
  maxActionExpiry: 7 * 24 * 3600,
@@ -100,8 +109,12 @@ var VILINK_CONSTANTS = {
100
109
  // 0.1 VCoin
101
110
  maxTipAmount: 1e4,
102
111
  // 10,000 VCoin
103
- platformFeeBps: 250
112
+ platformFeeBps: 250,
104
113
  // 2.5%
114
+ maxPlatformFeeBps: 1e3,
115
+ // M-02: 10% max
116
+ minPlatformFeeBps: 10
117
+ // M-02: 0.1% min
105
118
  };
106
119
  var ACTION_SCOPES = {
107
120
  tip: 1 << 0,
@@ -127,7 +140,9 @@ var GASLESS_CONSTANTS = {
127
140
  // 1%
128
141
  dailySubsidyBudget: 10,
129
142
  // 10 SOL
130
- maxSubsidizedPerUser: 50
143
+ maxSubsidizedPerUser: 50,
144
+ maxSlippageBps: 500
145
+ // L-03: 5% max slippage for fee conversion
131
146
  };
132
147
  var FIVE_A_CONSTANTS = {
133
148
  maxScore: 1e4,
@@ -150,7 +165,15 @@ var FIVE_A_CONSTANTS = {
150
165
  "40-60": 0.7,
151
166
  "60-80": 1,
152
167
  "80-100": 1.2
153
- }
168
+ },
169
+ // H-05: Oracle consensus
170
+ oracleConsensusRequired: 3,
171
+ // 3-of-N oracles must agree
172
+ pendingScoreExpiry: 3600,
173
+ // 1 hour
174
+ // L-07: Rate limiting
175
+ minScoreUpdateInterval: 3600
176
+ // 1 hour between updates for same user
154
177
  };
155
178
  var CONTENT_CONSTANTS = {
156
179
  maxEnergy: 100,
@@ -169,9 +192,56 @@ var GOVERNANCE_CONSTANTS = {
169
192
  // 2 days
170
193
  vetoWindow: 24 * 3600,
171
194
  // 1 day
172
- quorumBps: 400
195
+ quorumBps: 400,
173
196
  // 4%
197
+ zkVotingEnabled: false
198
+ // C-01: Disabled until proper ZK infrastructure
199
+ };
200
+ var SECURITY_CONSTANTS = {
201
+ // H-02: Two-step authority transfer
202
+ authorityTransferTimelock: 24 * 3600,
203
+ // 24 hours
204
+ // H-01: Governance-controlled slashing
205
+ slashApprovalTimelock: 48 * 3600,
206
+ // 48 hours
207
+ slashExpiry: 7 * 24 * 3600,
208
+ // 7 days
209
+ // L-03: Slippage protection for gasless fees
210
+ maxFeeSlippageBps: 500,
211
+ // 5% max slippage
212
+ // L-07: Oracle rate limiting
213
+ minScoreUpdateInterval: 3600,
214
+ // 1 hour between updates for same user
215
+ // M-05: Circuit breaker cooldown
216
+ circuitBreakerCooldown: 21600,
217
+ // 6 hours (6 * 3600)
218
+ // H-05: Oracle consensus
219
+ oracleConsensusRequired: 3,
220
+ // 3-of-N oracles must agree
221
+ pendingScoreExpiry: 3600,
222
+ // 1 hour
223
+ // M-02: Platform fee bounds (ViLink)
224
+ maxPlatformFeeBps: 1e3,
225
+ // 10% max
226
+ minPlatformFeeBps: 10,
227
+ // 0.1% min
228
+ // v2.8.0 Phase 5 additions
229
+ merkleProofMaxSize: 32,
230
+ // H-NEW-02: Max proof levels (supports 4B+ users)
231
+ maxEpochBitmap: 1023,
232
+ // H-NEW-04: Max epoch with bitmap storage (85+ years)
233
+ votingPowerVerifiedOnChain: true
234
+ // C-NEW-01: Params read from chain, not passed
235
+ };
236
+ var VALID_URI_PREFIXES = ["ipfs://", "https://", "ar://"];
237
+ var MAX_URI_LENGTH = 128;
238
+ var MERKLE_CONSTANTS = {
239
+ leafDomainPrefix: "SSCRE_CLAIM_V1"
240
+ // Domain separation for merkle leaves
174
241
  };
242
+ var MERKLE_PROOF_MAX_SIZE = 32;
243
+ var MAX_EPOCH_BITMAP = 1023;
244
+ var LEGACY_SLASH_DEPRECATED = true;
175
245
 
176
246
  // src/core/index.ts
177
247
  var ViWoConnection = class {
@@ -440,6 +510,13 @@ function dateToTimestamp(date) {
440
510
  }
441
511
 
442
512
  // src/types.ts
513
+ var SlashStatus = /* @__PURE__ */ ((SlashStatus2) => {
514
+ SlashStatus2[SlashStatus2["Proposed"] = 0] = "Proposed";
515
+ SlashStatus2[SlashStatus2["Approved"] = 1] = "Approved";
516
+ SlashStatus2[SlashStatus2["Executed"] = 2] = "Executed";
517
+ SlashStatus2[SlashStatus2["Cancelled"] = 3] = "Cancelled";
518
+ return SlashStatus2;
519
+ })(SlashStatus || {});
443
520
  var StakingTier = /* @__PURE__ */ ((StakingTier2) => {
444
521
  StakingTier2[StakingTier2["None"] = 0] = "None";
445
522
  StakingTier2[StakingTier2["Bronze"] = 1] = "Bronze";
@@ -456,6 +533,12 @@ var ProposalStatus = /* @__PURE__ */ ((ProposalStatus2) => {
456
533
  ProposalStatus2[ProposalStatus2["Cancelled"] = 4] = "Cancelled";
457
534
  return ProposalStatus2;
458
535
  })(ProposalStatus || {});
536
+ var VoteChoice = /* @__PURE__ */ ((VoteChoice2) => {
537
+ VoteChoice2[VoteChoice2["Against"] = 0] = "Against";
538
+ VoteChoice2[VoteChoice2["For"] = 1] = "For";
539
+ VoteChoice2[VoteChoice2["Abstain"] = 2] = "Abstain";
540
+ return VoteChoice2;
541
+ })(VoteChoice || {});
459
542
  var ActionType = /* @__PURE__ */ ((ActionType2) => {
460
543
  ActionType2[ActionType2["Tip"] = 0] = "Tip";
461
544
  ActionType2[ActionType2["Vouch"] = 1] = "Vouch";
@@ -856,6 +939,13 @@ var GovernanceClient = class {
856
939
  }
857
940
  /**
858
941
  * Build vote transaction
942
+ *
943
+ * @note v2.8.0 (C-NEW-01): Voting power parameters (vevcoin_balance, five_a_score, tier)
944
+ * are now read from on-chain state, not passed as parameters. This prevents vote manipulation.
945
+ * The transaction only needs: proposal_id and choice (VoteChoice enum)
946
+ *
947
+ * @param proposalId - The proposal to vote on
948
+ * @param support - true = For, false = Against (use VoteChoice for more options)
859
949
  */
860
950
  async buildVoteTransaction(proposalId, support) {
861
951
  if (!this.client.publicKey) {
@@ -866,6 +956,7 @@ var GovernanceClient = class {
866
956
  throw new Error("Already voted on this proposal");
867
957
  }
868
958
  const tx = new Transaction3();
959
+ const choice = support ? 1 /* For */ : 0 /* Against */;
869
960
  return tx;
870
961
  }
871
962
  /**
@@ -2257,17 +2348,25 @@ export {
2257
2348
  GaslessClient,
2258
2349
  GovernanceClient,
2259
2350
  IdentityClient,
2351
+ LEGACY_SLASH_DEPRECATED,
2260
2352
  LOCK_DURATIONS,
2353
+ MAX_EPOCH_BITMAP,
2354
+ MAX_URI_LENGTH,
2355
+ MERKLE_CONSTANTS,
2356
+ MERKLE_PROOF_MAX_SIZE,
2261
2357
  PDAs,
2262
2358
  PROGRAM_IDS,
2263
2359
  ProposalStatus,
2264
2360
  RewardsClient,
2361
+ SECURITY_CONSTANTS,
2265
2362
  SEEDS,
2266
2363
  SSCRE_CONSTANTS,
2267
2364
  STAKING_TIERS,
2365
+ SlashStatus,
2268
2366
  StakingClient,
2269
2367
  StakingTier,
2270
2368
  TransactionBuilder,
2369
+ VALID_URI_PREFIXES,
2271
2370
  VCOIN_DECIMALS,
2272
2371
  VCOIN_INITIAL_CIRCULATING,
2273
2372
  VCOIN_TOTAL_SUPPLY,
@@ -2277,6 +2376,7 @@ export {
2277
2376
  ViLinkClient,
2278
2377
  ViWoClient,
2279
2378
  ViWoConnection,
2379
+ VoteChoice,
2280
2380
  dateToTimestamp,
2281
2381
  formatVCoin,
2282
2382
  getCurrentTimestamp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viwoapp/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "ViWoApp SDK - TypeScript SDK for VCoin Protocol Integration",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -31,7 +31,10 @@
31
31
  "bs58": "^5.0.0"
32
32
  },
33
33
  "devDependencies": {
34
+ "@types/jest": "^29.5.0",
34
35
  "@types/node": "^20.0.0",
36
+ "jest": "^29.7.0",
37
+ "ts-jest": "^29.1.0",
35
38
  "tsup": "^8.0.0",
36
39
  "typescript": "^5.0.0"
37
40
  },