@viwoapp/sdk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/index.d.mts +133 -6
- package/dist/index.d.ts +133 -6
- package/dist/index.js +83 -6
- package/dist/index.mjs +78 -6
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
# @viwoapp/sdk
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@viwoapp/sdk)
|
|
4
|
+
[](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,6 +163,24 @@ declare const GOVERNANCE_CONSTANTS: {
|
|
|
153
163
|
executionDelay: number;
|
|
154
164
|
vetoWindow: number;
|
|
155
165
|
quorumBps: number;
|
|
166
|
+
zkVotingEnabled: boolean;
|
|
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
|
+
};
|
|
180
|
+
declare const VALID_URI_PREFIXES: readonly ["ipfs://", "https://", "ar://"];
|
|
181
|
+
declare const MAX_URI_LENGTH = 128;
|
|
182
|
+
declare const MERKLE_CONSTANTS: {
|
|
183
|
+
leafDomainPrefix: string;
|
|
156
184
|
};
|
|
157
185
|
|
|
158
186
|
interface ConnectionConfig {
|
|
@@ -237,7 +265,12 @@ declare function getCurrentTimestamp(): number;
|
|
|
237
265
|
declare function timestampToDate(timestamp: number | BN): Date;
|
|
238
266
|
declare function dateToTimestamp(date: Date): number;
|
|
239
267
|
|
|
240
|
-
|
|
268
|
+
/** Two-step authority transfer fields (H-02) */
|
|
269
|
+
interface PendingAuthorityFields {
|
|
270
|
+
pendingAuthority?: PublicKey;
|
|
271
|
+
pendingAuthorityActivatedAt?: BN;
|
|
272
|
+
}
|
|
273
|
+
interface VCoinConfig extends PendingAuthorityFields {
|
|
241
274
|
authority: PublicKey;
|
|
242
275
|
mint: PublicKey;
|
|
243
276
|
permanentDelegate: PublicKey;
|
|
@@ -245,6 +278,24 @@ interface VCoinConfig {
|
|
|
245
278
|
totalMinted: BN;
|
|
246
279
|
totalBurned: BN;
|
|
247
280
|
}
|
|
281
|
+
/** Governance-controlled slashing request (H-01) */
|
|
282
|
+
declare enum SlashStatus {
|
|
283
|
+
Proposed = 0,
|
|
284
|
+
Approved = 1,
|
|
285
|
+
Executed = 2,
|
|
286
|
+
Cancelled = 3
|
|
287
|
+
}
|
|
288
|
+
interface SlashRequest {
|
|
289
|
+
target: PublicKey;
|
|
290
|
+
amount: BN;
|
|
291
|
+
reason: Uint8Array;
|
|
292
|
+
proposer: PublicKey;
|
|
293
|
+
proposedAt: BN;
|
|
294
|
+
approvedAt?: BN;
|
|
295
|
+
executedAt?: BN;
|
|
296
|
+
status: SlashStatus;
|
|
297
|
+
governanceProposal?: PublicKey;
|
|
298
|
+
}
|
|
248
299
|
declare enum StakingTier {
|
|
249
300
|
None = 0,
|
|
250
301
|
Bronze = 1,
|
|
@@ -252,13 +303,14 @@ declare enum StakingTier {
|
|
|
252
303
|
Gold = 3,
|
|
253
304
|
Platinum = 4
|
|
254
305
|
}
|
|
255
|
-
interface StakingPool {
|
|
306
|
+
interface StakingPool extends PendingAuthorityFields {
|
|
256
307
|
authority: PublicKey;
|
|
257
308
|
vcoinMint: PublicKey;
|
|
258
309
|
vevcoinMint: PublicKey;
|
|
259
310
|
totalStaked: BN;
|
|
260
311
|
totalVevcoinMinted: BN;
|
|
261
312
|
paused: boolean;
|
|
313
|
+
reentrancyGuard?: boolean;
|
|
262
314
|
}
|
|
263
315
|
interface UserStake {
|
|
264
316
|
user: PublicKey;
|
|
@@ -305,13 +357,15 @@ interface CreateProposalParams {
|
|
|
305
357
|
category: number;
|
|
306
358
|
durationDays: number;
|
|
307
359
|
}
|
|
308
|
-
interface RewardsPoolConfig {
|
|
360
|
+
interface RewardsPoolConfig extends PendingAuthorityFields {
|
|
309
361
|
authority: PublicKey;
|
|
310
362
|
vcoinMint: PublicKey;
|
|
311
363
|
currentEpoch: BN;
|
|
312
364
|
totalDistributed: BN;
|
|
313
365
|
remainingReserves: BN;
|
|
314
366
|
paused: boolean;
|
|
367
|
+
circuitBreakerActive?: boolean;
|
|
368
|
+
circuitBreakerTriggeredAt?: BN;
|
|
315
369
|
}
|
|
316
370
|
interface EpochDistribution {
|
|
317
371
|
epoch: BN;
|
|
@@ -326,6 +380,9 @@ interface UserClaim {
|
|
|
326
380
|
lastClaimedEpoch: BN;
|
|
327
381
|
totalClaimed: BN;
|
|
328
382
|
claimsCount: number;
|
|
383
|
+
claimedEpochsBitmap?: BN[];
|
|
384
|
+
claimedEpochsBitmapExt?: BN[];
|
|
385
|
+
highEpochsClaimed?: BN[];
|
|
329
386
|
}
|
|
330
387
|
interface ClaimRewardsParams {
|
|
331
388
|
epoch: BN;
|
|
@@ -342,7 +399,7 @@ declare enum ActionType {
|
|
|
342
399
|
Delegate = 6,
|
|
343
400
|
Vote = 7
|
|
344
401
|
}
|
|
345
|
-
interface ViLinkConfig {
|
|
402
|
+
interface ViLinkConfig extends PendingAuthorityFields {
|
|
346
403
|
authority: PublicKey;
|
|
347
404
|
vcoinMint: PublicKey;
|
|
348
405
|
treasury: PublicKey;
|
|
@@ -379,7 +436,7 @@ declare enum FeeMethod {
|
|
|
379
436
|
VCoinDeduction = 1,
|
|
380
437
|
SSCREDeduction = 2
|
|
381
438
|
}
|
|
382
|
-
interface GaslessConfig {
|
|
439
|
+
interface GaslessConfig extends PendingAuthorityFields {
|
|
383
440
|
authority: PublicKey;
|
|
384
441
|
feePayer: PublicKey;
|
|
385
442
|
vcoinMint: PublicKey;
|
|
@@ -389,6 +446,7 @@ interface GaslessConfig {
|
|
|
389
446
|
totalSubsidizedTx: BN;
|
|
390
447
|
totalVcoinCollected: BN;
|
|
391
448
|
paused: boolean;
|
|
449
|
+
maxSlippageBps?: number;
|
|
392
450
|
}
|
|
393
451
|
interface SessionKey {
|
|
394
452
|
user: PublicKey;
|
|
@@ -474,6 +532,75 @@ interface UserEnergy {
|
|
|
474
532
|
lastRegenTime: BN;
|
|
475
533
|
tier: number;
|
|
476
534
|
}
|
|
535
|
+
interface RegistryConfig extends PendingAuthorityFields {
|
|
536
|
+
authority: PublicKey;
|
|
537
|
+
paused: boolean;
|
|
538
|
+
totalContent: BN;
|
|
539
|
+
}
|
|
540
|
+
interface IdentityConfig extends PendingAuthorityFields {
|
|
541
|
+
authority: PublicKey;
|
|
542
|
+
paused: boolean;
|
|
543
|
+
totalIdentities: BN;
|
|
544
|
+
}
|
|
545
|
+
interface FiveAConfig extends PendingAuthorityFields {
|
|
546
|
+
authority: PublicKey;
|
|
547
|
+
paused: boolean;
|
|
548
|
+
oracleConsensusRequired: number;
|
|
549
|
+
}
|
|
550
|
+
interface GovernanceConfig extends PendingAuthorityFields {
|
|
551
|
+
authority: PublicKey;
|
|
552
|
+
vevcoinMint: PublicKey;
|
|
553
|
+
paused: boolean;
|
|
554
|
+
proposalCount: BN;
|
|
555
|
+
zkVotingEnabled: boolean;
|
|
556
|
+
}
|
|
557
|
+
/** ZK voting decryption share storage (C-02) */
|
|
558
|
+
interface DecryptionShare {
|
|
559
|
+
proposal: PublicKey;
|
|
560
|
+
committeeIndex: number;
|
|
561
|
+
committeeMember: PublicKey;
|
|
562
|
+
share: Uint8Array;
|
|
563
|
+
submittedAt: BN;
|
|
564
|
+
}
|
|
565
|
+
/** Private voting config with committee tracking (C-02) */
|
|
566
|
+
interface PrivateVotingConfig {
|
|
567
|
+
proposal: PublicKey;
|
|
568
|
+
encryptionPubkey: PublicKey;
|
|
569
|
+
decryptionThreshold: number;
|
|
570
|
+
decryptionCommittee: PublicKey[];
|
|
571
|
+
sharesSubmitted: boolean[];
|
|
572
|
+
revealCompleted: boolean;
|
|
573
|
+
aggregatedFor: BN;
|
|
574
|
+
aggregatedAgainst: BN;
|
|
575
|
+
}
|
|
576
|
+
/** Delegation with expiry (M-07) */
|
|
577
|
+
interface Delegation {
|
|
578
|
+
delegator: PublicKey;
|
|
579
|
+
delegate: PublicKey;
|
|
580
|
+
delegationType: number;
|
|
581
|
+
delegatedAmount: BN;
|
|
582
|
+
expiresAt?: BN;
|
|
583
|
+
revocable: boolean;
|
|
584
|
+
}
|
|
585
|
+
/** Pending score update for oracle consensus */
|
|
586
|
+
interface PendingScoreUpdate {
|
|
587
|
+
user: PublicKey;
|
|
588
|
+
authenticity: number;
|
|
589
|
+
accuracy: number;
|
|
590
|
+
agility: number;
|
|
591
|
+
activity: number;
|
|
592
|
+
approved: number;
|
|
593
|
+
oracleSubmissions: PublicKey[];
|
|
594
|
+
submissionCount: number;
|
|
595
|
+
createdAt: BN;
|
|
596
|
+
expiresAt: BN;
|
|
597
|
+
}
|
|
598
|
+
interface HookConfig extends PendingAuthorityFields {
|
|
599
|
+
authority: PublicKey;
|
|
600
|
+
vcoinMint: PublicKey;
|
|
601
|
+
blockWashTrading: boolean;
|
|
602
|
+
paused: boolean;
|
|
603
|
+
}
|
|
477
604
|
|
|
478
605
|
/**
|
|
479
606
|
* Governance Client for ViWoApp governance operations
|
|
@@ -1196,4 +1323,4 @@ declare class StakingClient {
|
|
|
1196
1323
|
buildExtendLockTransaction(newDuration: number): Promise<Transaction>;
|
|
1197
1324
|
}
|
|
1198
1325
|
|
|
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 };
|
|
1326
|
+
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, LOCK_DURATIONS, MAX_URI_LENGTH, MERKLE_CONSTANTS, 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, 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,6 +163,24 @@ declare const GOVERNANCE_CONSTANTS: {
|
|
|
153
163
|
executionDelay: number;
|
|
154
164
|
vetoWindow: number;
|
|
155
165
|
quorumBps: number;
|
|
166
|
+
zkVotingEnabled: boolean;
|
|
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
|
+
};
|
|
180
|
+
declare const VALID_URI_PREFIXES: readonly ["ipfs://", "https://", "ar://"];
|
|
181
|
+
declare const MAX_URI_LENGTH = 128;
|
|
182
|
+
declare const MERKLE_CONSTANTS: {
|
|
183
|
+
leafDomainPrefix: string;
|
|
156
184
|
};
|
|
157
185
|
|
|
158
186
|
interface ConnectionConfig {
|
|
@@ -237,7 +265,12 @@ declare function getCurrentTimestamp(): number;
|
|
|
237
265
|
declare function timestampToDate(timestamp: number | BN): Date;
|
|
238
266
|
declare function dateToTimestamp(date: Date): number;
|
|
239
267
|
|
|
240
|
-
|
|
268
|
+
/** Two-step authority transfer fields (H-02) */
|
|
269
|
+
interface PendingAuthorityFields {
|
|
270
|
+
pendingAuthority?: PublicKey;
|
|
271
|
+
pendingAuthorityActivatedAt?: BN;
|
|
272
|
+
}
|
|
273
|
+
interface VCoinConfig extends PendingAuthorityFields {
|
|
241
274
|
authority: PublicKey;
|
|
242
275
|
mint: PublicKey;
|
|
243
276
|
permanentDelegate: PublicKey;
|
|
@@ -245,6 +278,24 @@ interface VCoinConfig {
|
|
|
245
278
|
totalMinted: BN;
|
|
246
279
|
totalBurned: BN;
|
|
247
280
|
}
|
|
281
|
+
/** Governance-controlled slashing request (H-01) */
|
|
282
|
+
declare enum SlashStatus {
|
|
283
|
+
Proposed = 0,
|
|
284
|
+
Approved = 1,
|
|
285
|
+
Executed = 2,
|
|
286
|
+
Cancelled = 3
|
|
287
|
+
}
|
|
288
|
+
interface SlashRequest {
|
|
289
|
+
target: PublicKey;
|
|
290
|
+
amount: BN;
|
|
291
|
+
reason: Uint8Array;
|
|
292
|
+
proposer: PublicKey;
|
|
293
|
+
proposedAt: BN;
|
|
294
|
+
approvedAt?: BN;
|
|
295
|
+
executedAt?: BN;
|
|
296
|
+
status: SlashStatus;
|
|
297
|
+
governanceProposal?: PublicKey;
|
|
298
|
+
}
|
|
248
299
|
declare enum StakingTier {
|
|
249
300
|
None = 0,
|
|
250
301
|
Bronze = 1,
|
|
@@ -252,13 +303,14 @@ declare enum StakingTier {
|
|
|
252
303
|
Gold = 3,
|
|
253
304
|
Platinum = 4
|
|
254
305
|
}
|
|
255
|
-
interface StakingPool {
|
|
306
|
+
interface StakingPool extends PendingAuthorityFields {
|
|
256
307
|
authority: PublicKey;
|
|
257
308
|
vcoinMint: PublicKey;
|
|
258
309
|
vevcoinMint: PublicKey;
|
|
259
310
|
totalStaked: BN;
|
|
260
311
|
totalVevcoinMinted: BN;
|
|
261
312
|
paused: boolean;
|
|
313
|
+
reentrancyGuard?: boolean;
|
|
262
314
|
}
|
|
263
315
|
interface UserStake {
|
|
264
316
|
user: PublicKey;
|
|
@@ -305,13 +357,15 @@ interface CreateProposalParams {
|
|
|
305
357
|
category: number;
|
|
306
358
|
durationDays: number;
|
|
307
359
|
}
|
|
308
|
-
interface RewardsPoolConfig {
|
|
360
|
+
interface RewardsPoolConfig extends PendingAuthorityFields {
|
|
309
361
|
authority: PublicKey;
|
|
310
362
|
vcoinMint: PublicKey;
|
|
311
363
|
currentEpoch: BN;
|
|
312
364
|
totalDistributed: BN;
|
|
313
365
|
remainingReserves: BN;
|
|
314
366
|
paused: boolean;
|
|
367
|
+
circuitBreakerActive?: boolean;
|
|
368
|
+
circuitBreakerTriggeredAt?: BN;
|
|
315
369
|
}
|
|
316
370
|
interface EpochDistribution {
|
|
317
371
|
epoch: BN;
|
|
@@ -326,6 +380,9 @@ interface UserClaim {
|
|
|
326
380
|
lastClaimedEpoch: BN;
|
|
327
381
|
totalClaimed: BN;
|
|
328
382
|
claimsCount: number;
|
|
383
|
+
claimedEpochsBitmap?: BN[];
|
|
384
|
+
claimedEpochsBitmapExt?: BN[];
|
|
385
|
+
highEpochsClaimed?: BN[];
|
|
329
386
|
}
|
|
330
387
|
interface ClaimRewardsParams {
|
|
331
388
|
epoch: BN;
|
|
@@ -342,7 +399,7 @@ declare enum ActionType {
|
|
|
342
399
|
Delegate = 6,
|
|
343
400
|
Vote = 7
|
|
344
401
|
}
|
|
345
|
-
interface ViLinkConfig {
|
|
402
|
+
interface ViLinkConfig extends PendingAuthorityFields {
|
|
346
403
|
authority: PublicKey;
|
|
347
404
|
vcoinMint: PublicKey;
|
|
348
405
|
treasury: PublicKey;
|
|
@@ -379,7 +436,7 @@ declare enum FeeMethod {
|
|
|
379
436
|
VCoinDeduction = 1,
|
|
380
437
|
SSCREDeduction = 2
|
|
381
438
|
}
|
|
382
|
-
interface GaslessConfig {
|
|
439
|
+
interface GaslessConfig extends PendingAuthorityFields {
|
|
383
440
|
authority: PublicKey;
|
|
384
441
|
feePayer: PublicKey;
|
|
385
442
|
vcoinMint: PublicKey;
|
|
@@ -389,6 +446,7 @@ interface GaslessConfig {
|
|
|
389
446
|
totalSubsidizedTx: BN;
|
|
390
447
|
totalVcoinCollected: BN;
|
|
391
448
|
paused: boolean;
|
|
449
|
+
maxSlippageBps?: number;
|
|
392
450
|
}
|
|
393
451
|
interface SessionKey {
|
|
394
452
|
user: PublicKey;
|
|
@@ -474,6 +532,75 @@ interface UserEnergy {
|
|
|
474
532
|
lastRegenTime: BN;
|
|
475
533
|
tier: number;
|
|
476
534
|
}
|
|
535
|
+
interface RegistryConfig extends PendingAuthorityFields {
|
|
536
|
+
authority: PublicKey;
|
|
537
|
+
paused: boolean;
|
|
538
|
+
totalContent: BN;
|
|
539
|
+
}
|
|
540
|
+
interface IdentityConfig extends PendingAuthorityFields {
|
|
541
|
+
authority: PublicKey;
|
|
542
|
+
paused: boolean;
|
|
543
|
+
totalIdentities: BN;
|
|
544
|
+
}
|
|
545
|
+
interface FiveAConfig extends PendingAuthorityFields {
|
|
546
|
+
authority: PublicKey;
|
|
547
|
+
paused: boolean;
|
|
548
|
+
oracleConsensusRequired: number;
|
|
549
|
+
}
|
|
550
|
+
interface GovernanceConfig extends PendingAuthorityFields {
|
|
551
|
+
authority: PublicKey;
|
|
552
|
+
vevcoinMint: PublicKey;
|
|
553
|
+
paused: boolean;
|
|
554
|
+
proposalCount: BN;
|
|
555
|
+
zkVotingEnabled: boolean;
|
|
556
|
+
}
|
|
557
|
+
/** ZK voting decryption share storage (C-02) */
|
|
558
|
+
interface DecryptionShare {
|
|
559
|
+
proposal: PublicKey;
|
|
560
|
+
committeeIndex: number;
|
|
561
|
+
committeeMember: PublicKey;
|
|
562
|
+
share: Uint8Array;
|
|
563
|
+
submittedAt: BN;
|
|
564
|
+
}
|
|
565
|
+
/** Private voting config with committee tracking (C-02) */
|
|
566
|
+
interface PrivateVotingConfig {
|
|
567
|
+
proposal: PublicKey;
|
|
568
|
+
encryptionPubkey: PublicKey;
|
|
569
|
+
decryptionThreshold: number;
|
|
570
|
+
decryptionCommittee: PublicKey[];
|
|
571
|
+
sharesSubmitted: boolean[];
|
|
572
|
+
revealCompleted: boolean;
|
|
573
|
+
aggregatedFor: BN;
|
|
574
|
+
aggregatedAgainst: BN;
|
|
575
|
+
}
|
|
576
|
+
/** Delegation with expiry (M-07) */
|
|
577
|
+
interface Delegation {
|
|
578
|
+
delegator: PublicKey;
|
|
579
|
+
delegate: PublicKey;
|
|
580
|
+
delegationType: number;
|
|
581
|
+
delegatedAmount: BN;
|
|
582
|
+
expiresAt?: BN;
|
|
583
|
+
revocable: boolean;
|
|
584
|
+
}
|
|
585
|
+
/** Pending score update for oracle consensus */
|
|
586
|
+
interface PendingScoreUpdate {
|
|
587
|
+
user: PublicKey;
|
|
588
|
+
authenticity: number;
|
|
589
|
+
accuracy: number;
|
|
590
|
+
agility: number;
|
|
591
|
+
activity: number;
|
|
592
|
+
approved: number;
|
|
593
|
+
oracleSubmissions: PublicKey[];
|
|
594
|
+
submissionCount: number;
|
|
595
|
+
createdAt: BN;
|
|
596
|
+
expiresAt: BN;
|
|
597
|
+
}
|
|
598
|
+
interface HookConfig extends PendingAuthorityFields {
|
|
599
|
+
authority: PublicKey;
|
|
600
|
+
vcoinMint: PublicKey;
|
|
601
|
+
blockWashTrading: boolean;
|
|
602
|
+
paused: boolean;
|
|
603
|
+
}
|
|
477
604
|
|
|
478
605
|
/**
|
|
479
606
|
* Governance Client for ViWoApp governance operations
|
|
@@ -1196,4 +1323,4 @@ declare class StakingClient {
|
|
|
1196
1323
|
buildExtendLockTransaction(newDuration: number): Promise<Transaction>;
|
|
1197
1324
|
}
|
|
1198
1325
|
|
|
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 };
|
|
1326
|
+
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, LOCK_DURATIONS, MAX_URI_LENGTH, MERKLE_CONSTANTS, 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, type VoteRecord, type VouchRecord, type WalletAdapter, dateToTimestamp, formatVCoin, getCurrentTimestamp, parseVCoin, timestampToDate };
|
package/dist/index.js
CHANGED
|
@@ -35,16 +35,21 @@ __export(index_exports, {
|
|
|
35
35
|
GovernanceClient: () => GovernanceClient,
|
|
36
36
|
IdentityClient: () => IdentityClient,
|
|
37
37
|
LOCK_DURATIONS: () => LOCK_DURATIONS,
|
|
38
|
+
MAX_URI_LENGTH: () => MAX_URI_LENGTH,
|
|
39
|
+
MERKLE_CONSTANTS: () => MERKLE_CONSTANTS,
|
|
38
40
|
PDAs: () => PDAs,
|
|
39
41
|
PROGRAM_IDS: () => PROGRAM_IDS,
|
|
40
42
|
ProposalStatus: () => ProposalStatus,
|
|
41
43
|
RewardsClient: () => RewardsClient,
|
|
44
|
+
SECURITY_CONSTANTS: () => SECURITY_CONSTANTS,
|
|
42
45
|
SEEDS: () => SEEDS,
|
|
43
46
|
SSCRE_CONSTANTS: () => SSCRE_CONSTANTS,
|
|
44
47
|
STAKING_TIERS: () => STAKING_TIERS,
|
|
48
|
+
SlashStatus: () => SlashStatus,
|
|
45
49
|
StakingClient: () => StakingClient,
|
|
46
50
|
StakingTier: () => StakingTier,
|
|
47
51
|
TransactionBuilder: () => TransactionBuilder,
|
|
52
|
+
VALID_URI_PREFIXES: () => VALID_URI_PREFIXES,
|
|
48
53
|
VCOIN_DECIMALS: () => VCOIN_DECIMALS,
|
|
49
54
|
VCOIN_INITIAL_CIRCULATING: () => VCOIN_INITIAL_CIRCULATING,
|
|
50
55
|
VCOIN_TOTAL_SUPPLY: () => VCOIN_TOTAL_SUPPLY,
|
|
@@ -119,7 +124,14 @@ var SEEDS = {
|
|
|
119
124
|
// Content
|
|
120
125
|
registryConfig: "registry-config",
|
|
121
126
|
content: "content",
|
|
122
|
-
userEnergy: "user-energy"
|
|
127
|
+
userEnergy: "user-energy",
|
|
128
|
+
// Security (Phase 2-4)
|
|
129
|
+
slashRequest: "slash-request",
|
|
130
|
+
// H-01: Governance slashing
|
|
131
|
+
decryptionShare: "decryption-share",
|
|
132
|
+
// C-02: ZK voting shares
|
|
133
|
+
pendingScore: "pending-score"
|
|
134
|
+
// H-05: Oracle consensus
|
|
123
135
|
};
|
|
124
136
|
var VCOIN_DECIMALS = 9;
|
|
125
137
|
var VEVCOIN_DECIMALS = 9;
|
|
@@ -150,8 +162,10 @@ var SSCRE_CONSTANTS = {
|
|
|
150
162
|
// 90 days
|
|
151
163
|
gaslessFeeBps: 100,
|
|
152
164
|
// 1%
|
|
153
|
-
minClaimAmount: 1
|
|
165
|
+
minClaimAmount: 1,
|
|
154
166
|
// 1 VCoin
|
|
167
|
+
circuitBreakerCooldown: 21600
|
|
168
|
+
// M-05: 6 hours before reset
|
|
155
169
|
};
|
|
156
170
|
var VILINK_CONSTANTS = {
|
|
157
171
|
maxActionExpiry: 7 * 24 * 3600,
|
|
@@ -160,8 +174,12 @@ var VILINK_CONSTANTS = {
|
|
|
160
174
|
// 0.1 VCoin
|
|
161
175
|
maxTipAmount: 1e4,
|
|
162
176
|
// 10,000 VCoin
|
|
163
|
-
platformFeeBps: 250
|
|
177
|
+
platformFeeBps: 250,
|
|
164
178
|
// 2.5%
|
|
179
|
+
maxPlatformFeeBps: 1e3,
|
|
180
|
+
// M-02: 10% max
|
|
181
|
+
minPlatformFeeBps: 10
|
|
182
|
+
// M-02: 0.1% min
|
|
165
183
|
};
|
|
166
184
|
var ACTION_SCOPES = {
|
|
167
185
|
tip: 1 << 0,
|
|
@@ -187,7 +205,9 @@ var GASLESS_CONSTANTS = {
|
|
|
187
205
|
// 1%
|
|
188
206
|
dailySubsidyBudget: 10,
|
|
189
207
|
// 10 SOL
|
|
190
|
-
maxSubsidizedPerUser: 50
|
|
208
|
+
maxSubsidizedPerUser: 50,
|
|
209
|
+
maxSlippageBps: 500
|
|
210
|
+
// L-03: 5% max slippage for fee conversion
|
|
191
211
|
};
|
|
192
212
|
var FIVE_A_CONSTANTS = {
|
|
193
213
|
maxScore: 1e4,
|
|
@@ -210,7 +230,15 @@ var FIVE_A_CONSTANTS = {
|
|
|
210
230
|
"40-60": 0.7,
|
|
211
231
|
"60-80": 1,
|
|
212
232
|
"80-100": 1.2
|
|
213
|
-
}
|
|
233
|
+
},
|
|
234
|
+
// H-05: Oracle consensus
|
|
235
|
+
oracleConsensusRequired: 3,
|
|
236
|
+
// 3-of-N oracles must agree
|
|
237
|
+
pendingScoreExpiry: 3600,
|
|
238
|
+
// 1 hour
|
|
239
|
+
// L-07: Rate limiting
|
|
240
|
+
minScoreUpdateInterval: 3600
|
|
241
|
+
// 1 hour between updates for same user
|
|
214
242
|
};
|
|
215
243
|
var CONTENT_CONSTANTS = {
|
|
216
244
|
maxEnergy: 100,
|
|
@@ -229,8 +257,45 @@ var GOVERNANCE_CONSTANTS = {
|
|
|
229
257
|
// 2 days
|
|
230
258
|
vetoWindow: 24 * 3600,
|
|
231
259
|
// 1 day
|
|
232
|
-
quorumBps: 400
|
|
260
|
+
quorumBps: 400,
|
|
233
261
|
// 4%
|
|
262
|
+
zkVotingEnabled: false
|
|
263
|
+
// C-01: Disabled until proper ZK infrastructure
|
|
264
|
+
};
|
|
265
|
+
var SECURITY_CONSTANTS = {
|
|
266
|
+
// H-02: Two-step authority transfer
|
|
267
|
+
authorityTransferTimelock: 24 * 3600,
|
|
268
|
+
// 24 hours
|
|
269
|
+
// H-01: Governance-controlled slashing
|
|
270
|
+
slashApprovalTimelock: 48 * 3600,
|
|
271
|
+
// 48 hours
|
|
272
|
+
slashExpiry: 7 * 24 * 3600,
|
|
273
|
+
// 7 days
|
|
274
|
+
// L-03: Slippage protection for gasless fees
|
|
275
|
+
maxFeeSlippageBps: 500,
|
|
276
|
+
// 5% max slippage
|
|
277
|
+
// L-07: Oracle rate limiting
|
|
278
|
+
minScoreUpdateInterval: 3600,
|
|
279
|
+
// 1 hour between updates for same user
|
|
280
|
+
// M-05: Circuit breaker cooldown
|
|
281
|
+
circuitBreakerCooldown: 21600,
|
|
282
|
+
// 6 hours (6 * 3600)
|
|
283
|
+
// H-05: Oracle consensus
|
|
284
|
+
oracleConsensusRequired: 3,
|
|
285
|
+
// 3-of-N oracles must agree
|
|
286
|
+
pendingScoreExpiry: 3600,
|
|
287
|
+
// 1 hour
|
|
288
|
+
// M-02: Platform fee bounds (ViLink)
|
|
289
|
+
maxPlatformFeeBps: 1e3,
|
|
290
|
+
// 10% max
|
|
291
|
+
minPlatformFeeBps: 10
|
|
292
|
+
// 0.1% min
|
|
293
|
+
};
|
|
294
|
+
var VALID_URI_PREFIXES = ["ipfs://", "https://", "ar://"];
|
|
295
|
+
var MAX_URI_LENGTH = 128;
|
|
296
|
+
var MERKLE_CONSTANTS = {
|
|
297
|
+
leafDomainPrefix: "SSCRE_CLAIM_V1"
|
|
298
|
+
// Domain separation for merkle leaves
|
|
234
299
|
};
|
|
235
300
|
|
|
236
301
|
// src/core/index.ts
|
|
@@ -500,6 +565,13 @@ function dateToTimestamp(date) {
|
|
|
500
565
|
}
|
|
501
566
|
|
|
502
567
|
// src/types.ts
|
|
568
|
+
var SlashStatus = /* @__PURE__ */ ((SlashStatus2) => {
|
|
569
|
+
SlashStatus2[SlashStatus2["Proposed"] = 0] = "Proposed";
|
|
570
|
+
SlashStatus2[SlashStatus2["Approved"] = 1] = "Approved";
|
|
571
|
+
SlashStatus2[SlashStatus2["Executed"] = 2] = "Executed";
|
|
572
|
+
SlashStatus2[SlashStatus2["Cancelled"] = 3] = "Cancelled";
|
|
573
|
+
return SlashStatus2;
|
|
574
|
+
})(SlashStatus || {});
|
|
503
575
|
var StakingTier = /* @__PURE__ */ ((StakingTier2) => {
|
|
504
576
|
StakingTier2[StakingTier2["None"] = 0] = "None";
|
|
505
577
|
StakingTier2[StakingTier2["Bronze"] = 1] = "Bronze";
|
|
@@ -2319,16 +2391,21 @@ var ViWoClient = class {
|
|
|
2319
2391
|
GovernanceClient,
|
|
2320
2392
|
IdentityClient,
|
|
2321
2393
|
LOCK_DURATIONS,
|
|
2394
|
+
MAX_URI_LENGTH,
|
|
2395
|
+
MERKLE_CONSTANTS,
|
|
2322
2396
|
PDAs,
|
|
2323
2397
|
PROGRAM_IDS,
|
|
2324
2398
|
ProposalStatus,
|
|
2325
2399
|
RewardsClient,
|
|
2400
|
+
SECURITY_CONSTANTS,
|
|
2326
2401
|
SEEDS,
|
|
2327
2402
|
SSCRE_CONSTANTS,
|
|
2328
2403
|
STAKING_TIERS,
|
|
2404
|
+
SlashStatus,
|
|
2329
2405
|
StakingClient,
|
|
2330
2406
|
StakingTier,
|
|
2331
2407
|
TransactionBuilder,
|
|
2408
|
+
VALID_URI_PREFIXES,
|
|
2332
2409
|
VCOIN_DECIMALS,
|
|
2333
2410
|
VCOIN_INITIAL_CIRCULATING,
|
|
2334
2411
|
VCOIN_TOTAL_SUPPLY,
|
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,8 +192,45 @@ 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
|
+
};
|
|
229
|
+
var VALID_URI_PREFIXES = ["ipfs://", "https://", "ar://"];
|
|
230
|
+
var MAX_URI_LENGTH = 128;
|
|
231
|
+
var MERKLE_CONSTANTS = {
|
|
232
|
+
leafDomainPrefix: "SSCRE_CLAIM_V1"
|
|
233
|
+
// Domain separation for merkle leaves
|
|
174
234
|
};
|
|
175
235
|
|
|
176
236
|
// src/core/index.ts
|
|
@@ -440,6 +500,13 @@ function dateToTimestamp(date) {
|
|
|
440
500
|
}
|
|
441
501
|
|
|
442
502
|
// src/types.ts
|
|
503
|
+
var SlashStatus = /* @__PURE__ */ ((SlashStatus2) => {
|
|
504
|
+
SlashStatus2[SlashStatus2["Proposed"] = 0] = "Proposed";
|
|
505
|
+
SlashStatus2[SlashStatus2["Approved"] = 1] = "Approved";
|
|
506
|
+
SlashStatus2[SlashStatus2["Executed"] = 2] = "Executed";
|
|
507
|
+
SlashStatus2[SlashStatus2["Cancelled"] = 3] = "Cancelled";
|
|
508
|
+
return SlashStatus2;
|
|
509
|
+
})(SlashStatus || {});
|
|
443
510
|
var StakingTier = /* @__PURE__ */ ((StakingTier2) => {
|
|
444
511
|
StakingTier2[StakingTier2["None"] = 0] = "None";
|
|
445
512
|
StakingTier2[StakingTier2["Bronze"] = 1] = "Bronze";
|
|
@@ -2258,16 +2325,21 @@ export {
|
|
|
2258
2325
|
GovernanceClient,
|
|
2259
2326
|
IdentityClient,
|
|
2260
2327
|
LOCK_DURATIONS,
|
|
2328
|
+
MAX_URI_LENGTH,
|
|
2329
|
+
MERKLE_CONSTANTS,
|
|
2261
2330
|
PDAs,
|
|
2262
2331
|
PROGRAM_IDS,
|
|
2263
2332
|
ProposalStatus,
|
|
2264
2333
|
RewardsClient,
|
|
2334
|
+
SECURITY_CONSTANTS,
|
|
2265
2335
|
SEEDS,
|
|
2266
2336
|
SSCRE_CONSTANTS,
|
|
2267
2337
|
STAKING_TIERS,
|
|
2338
|
+
SlashStatus,
|
|
2268
2339
|
StakingClient,
|
|
2269
2340
|
StakingTier,
|
|
2270
2341
|
TransactionBuilder,
|
|
2342
|
+
VALID_URI_PREFIXES,
|
|
2271
2343
|
VCOIN_DECIMALS,
|
|
2272
2344
|
VCOIN_INITIAL_CIRCULATING,
|
|
2273
2345
|
VCOIN_TOTAL_SUPPLY,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viwoapp/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
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
|
},
|