@viwoapp/sdk 0.1.8 → 2.0.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 +667 -427
- package/dist/index.d.mts +307 -13
- package/dist/index.d.ts +307 -13
- package/dist/index.js +360 -17
- package/dist/index.mjs +360 -17
- package/package.json +82 -82
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicKey,
|
|
1
|
+
import { PublicKey, Commitment, Connection, Transaction, VersionedTransaction, TransactionInstruction } from '@solana/web3.js';
|
|
2
2
|
import { BN, AnchorProvider } from '@coral-xyz/anchor';
|
|
3
3
|
export { BN } from '@coral-xyz/anchor';
|
|
4
4
|
|
|
@@ -173,7 +173,20 @@ declare const GOVERNANCE_CONSTANTS: {
|
|
|
173
173
|
executionDelay: number;
|
|
174
174
|
vetoWindow: number;
|
|
175
175
|
quorumBps: number;
|
|
176
|
-
|
|
176
|
+
/** Authority transfer timelock (H-02) */
|
|
177
|
+
authorityTransferTimelock: number;
|
|
178
|
+
/** ZK private voting constants */
|
|
179
|
+
zk: {
|
|
180
|
+
/** Vote validity proof size (3 OR proofs + 1 sum proof) */
|
|
181
|
+
voteProofSize: number;
|
|
182
|
+
/** ElGamal ciphertext size (R || C) */
|
|
183
|
+
ciphertextSize: number;
|
|
184
|
+
/** Max committee members */
|
|
185
|
+
maxCommitteeSize: number;
|
|
186
|
+
/** Account sizes */
|
|
187
|
+
privateVotingConfigSize: number;
|
|
188
|
+
decryptionShareSize: number;
|
|
189
|
+
};
|
|
177
190
|
};
|
|
178
191
|
declare const SECURITY_CONSTANTS: {
|
|
179
192
|
authorityTransferTimelock: number;
|
|
@@ -189,6 +202,18 @@ declare const SECURITY_CONSTANTS: {
|
|
|
189
202
|
merkleProofMaxSize: number;
|
|
190
203
|
maxEpochBitmap: number;
|
|
191
204
|
votingPowerVerifiedOnChain: boolean;
|
|
205
|
+
/** H-AUDIT-12: Maximum concurrent sessions per user */
|
|
206
|
+
maxSessionsPerUser: number;
|
|
207
|
+
/** C-AUDIT-15: Maximum day delta for daily budget reset (clock skew protection) */
|
|
208
|
+
maxDayDelta: number;
|
|
209
|
+
/** H-AUDIT-09: Maximum daily activity score for transfer hook */
|
|
210
|
+
maxDailyActivityScore: number;
|
|
211
|
+
/** M-AUDIT-10: Wash flag decay period (7 days) */
|
|
212
|
+
washFlagDecayPeriod: number;
|
|
213
|
+
/** M-18: Maximum vouch age before expiry (1 year) */
|
|
214
|
+
maxVouchAge: number;
|
|
215
|
+
/** C-AUDIT-11: Valid content energy tiers (1-4) */
|
|
216
|
+
maxContentTier: number;
|
|
192
217
|
};
|
|
193
218
|
declare const VALID_URI_PREFIXES: readonly ["ipfs://", "https://", "ar://"];
|
|
194
219
|
declare const MAX_URI_LENGTH = 128;
|
|
@@ -247,6 +272,10 @@ declare class PDAs {
|
|
|
247
272
|
getGovernanceConfig(): PublicKey;
|
|
248
273
|
getProposal(proposalId: BN): PublicKey;
|
|
249
274
|
getVoteRecord(user: PublicKey, proposal: PublicKey): PublicKey;
|
|
275
|
+
/** H-NEW-03: Delegation PDA (one per delegator) */
|
|
276
|
+
getDelegation(delegator: PublicKey): PublicKey;
|
|
277
|
+
/** H-NEW-03: Delegate stats PDA (one per delegate) */
|
|
278
|
+
getDelegateStats(delegate: PublicKey): PublicKey;
|
|
250
279
|
getRewardsPoolConfig(): PublicKey;
|
|
251
280
|
getEpochDistribution(epoch: BN): PublicKey;
|
|
252
281
|
getUserClaim(user: PublicKey): PublicKey;
|
|
@@ -394,6 +423,12 @@ interface VoteRecord {
|
|
|
394
423
|
votePower: BN;
|
|
395
424
|
support: boolean;
|
|
396
425
|
votedAt: BN;
|
|
426
|
+
/** ElGamal ciphertext for "for" vote (64 bytes: R || C) - only set for private votes */
|
|
427
|
+
ctFor?: Uint8Array;
|
|
428
|
+
/** ElGamal ciphertext for "against" vote (64 bytes: R || C) - only set for private votes */
|
|
429
|
+
ctAgainst?: Uint8Array;
|
|
430
|
+
/** ElGamal ciphertext for "abstain" vote (64 bytes: R || C) - only set for private votes */
|
|
431
|
+
ctAbstain?: Uint8Array;
|
|
397
432
|
}
|
|
398
433
|
interface CreateProposalParams {
|
|
399
434
|
title: string;
|
|
@@ -574,6 +609,8 @@ interface UserGaslessStats {
|
|
|
574
609
|
totalVcoinFees: BN;
|
|
575
610
|
sessionsCreated: number;
|
|
576
611
|
activeSession: PublicKey;
|
|
612
|
+
/** H-AUDIT-12: Number of active (non-revoked, non-expired) sessions */
|
|
613
|
+
activeSessions: number;
|
|
577
614
|
}
|
|
578
615
|
declare enum VerificationLevel {
|
|
579
616
|
None = 0,// Wallet connected only
|
|
@@ -650,34 +687,77 @@ interface GovernanceConfig extends PendingAuthorityFields {
|
|
|
650
687
|
vevcoinMint: PublicKey;
|
|
651
688
|
paused: boolean;
|
|
652
689
|
proposalCount: BN;
|
|
653
|
-
|
|
690
|
+
/** H-02: Timestamp when pending authority transfer was initiated (for 24h timelock) */
|
|
691
|
+
pendingAuthorityActivatedAt: BN;
|
|
654
692
|
}
|
|
655
|
-
/** ZK voting decryption share
|
|
693
|
+
/** ZK voting decryption share with per-category partials and DLEQ proof */
|
|
656
694
|
interface DecryptionShare {
|
|
657
695
|
proposal: PublicKey;
|
|
658
696
|
committeeIndex: number;
|
|
659
697
|
committeeMember: PublicKey;
|
|
660
|
-
|
|
698
|
+
/** Partial decryption: sk_j * R_for_sum (Ristretto255 point) */
|
|
699
|
+
partialFor: Uint8Array;
|
|
700
|
+
/** Partial decryption: sk_j * R_against_sum (Ristretto255 point) */
|
|
701
|
+
partialAgainst: Uint8Array;
|
|
702
|
+
/** Partial decryption: sk_j * R_abstain_sum (Ristretto255 point) */
|
|
703
|
+
partialAbstain: Uint8Array;
|
|
704
|
+
/** Batched DLEQ proof challenge (Scalar) */
|
|
705
|
+
dleqChallenge: Uint8Array;
|
|
706
|
+
/** Batched DLEQ proof response (Scalar) */
|
|
707
|
+
dleqResponse: Uint8Array;
|
|
661
708
|
submittedAt: BN;
|
|
709
|
+
verified: boolean;
|
|
662
710
|
}
|
|
663
|
-
/** Private voting config with
|
|
711
|
+
/** Private voting config with ZK cryptographic verification */
|
|
664
712
|
interface PrivateVotingConfig {
|
|
665
713
|
proposal: PublicKey;
|
|
666
|
-
|
|
714
|
+
/** Joint ElGamal public key (Ristretto255 point, 32 bytes) */
|
|
715
|
+
encryptionPubkey: Uint8Array;
|
|
667
716
|
decryptionThreshold: number;
|
|
668
717
|
decryptionCommittee: PublicKey[];
|
|
718
|
+
/** Committee ElGamal public keys (Ristretto255 points) */
|
|
719
|
+
committeeElgamalPubkeys: Uint8Array[];
|
|
669
720
|
sharesSubmitted: boolean[];
|
|
670
721
|
revealCompleted: boolean;
|
|
671
722
|
aggregatedFor: BN;
|
|
672
723
|
aggregatedAgainst: BN;
|
|
724
|
+
aggregatedAbstain: BN;
|
|
725
|
+
/** Verification hash for audit trail */
|
|
726
|
+
verificationHash: Uint8Array;
|
|
727
|
+
/** Homomorphically accumulated ciphertext components */
|
|
728
|
+
accumulatedCtForR: Uint8Array;
|
|
729
|
+
accumulatedCtForC: Uint8Array;
|
|
730
|
+
accumulatedCtAgainstR: Uint8Array;
|
|
731
|
+
accumulatedCtAgainstC: Uint8Array;
|
|
732
|
+
accumulatedCtAbstainR: Uint8Array;
|
|
733
|
+
accumulatedCtAbstainC: Uint8Array;
|
|
734
|
+
/** Number of private votes cast */
|
|
735
|
+
totalPrivateVotes: number;
|
|
673
736
|
}
|
|
674
737
|
/** Delegation with expiry (M-07) */
|
|
675
738
|
interface Delegation {
|
|
676
739
|
delegator: PublicKey;
|
|
677
740
|
delegate: PublicKey;
|
|
678
741
|
delegationType: number;
|
|
742
|
+
categories: number;
|
|
679
743
|
delegatedAmount: BN;
|
|
680
|
-
|
|
744
|
+
delegatedAt: BN;
|
|
745
|
+
expiresAt: BN;
|
|
746
|
+
revocable: boolean;
|
|
747
|
+
}
|
|
748
|
+
/** H-NEW-03: Parameters for creating a delegation */
|
|
749
|
+
interface DelegateVotesParams {
|
|
750
|
+
/** Address to delegate voting power to */
|
|
751
|
+
delegate: PublicKey;
|
|
752
|
+
/** Delegation type (0=Full, 1=PerCategory, 2=TimeScoped) */
|
|
753
|
+
delegationType: number;
|
|
754
|
+
/** Category bitmap (0xFF for all) */
|
|
755
|
+
categories: number;
|
|
756
|
+
/** Amount of veVCoin to delegate (must be <= actual balance) */
|
|
757
|
+
amount: BN;
|
|
758
|
+
/** Expiration timestamp (0 = never expires) */
|
|
759
|
+
expiresAt: BN;
|
|
760
|
+
/** Whether the delegation can be revoked mid-vote */
|
|
681
761
|
revocable: boolean;
|
|
682
762
|
}
|
|
683
763
|
/** Pending score update for oracle consensus */
|
|
@@ -692,6 +772,8 @@ interface PendingScoreUpdate {
|
|
|
692
772
|
submissionCount: number;
|
|
693
773
|
createdAt: BN;
|
|
694
774
|
expiresAt: BN;
|
|
775
|
+
/** C-07: Immutable consensus count stored at creation time */
|
|
776
|
+
requiredConsensus: number;
|
|
695
777
|
}
|
|
696
778
|
interface HookConfig extends PendingAuthorityFields {
|
|
697
779
|
authority: PublicKey;
|
|
@@ -699,10 +781,82 @@ interface HookConfig extends PendingAuthorityFields {
|
|
|
699
781
|
blockWashTrading: boolean;
|
|
700
782
|
paused: boolean;
|
|
701
783
|
}
|
|
784
|
+
/** Pair tracking for wash trade detection */
|
|
785
|
+
interface PairTracking {
|
|
786
|
+
sender: PublicKey;
|
|
787
|
+
receiver: PublicKey;
|
|
788
|
+
transferCount: number;
|
|
789
|
+
lastTransferTime: BN;
|
|
790
|
+
washFlags: number;
|
|
791
|
+
/** M-AUDIT-10: Timestamp of last wash flag for decay */
|
|
792
|
+
lastFlagTime: BN;
|
|
793
|
+
}
|
|
794
|
+
interface VeVCoinConfig extends PendingAuthorityFields {
|
|
795
|
+
authority: PublicKey;
|
|
796
|
+
vcoinMint: PublicKey;
|
|
797
|
+
vevcoinMint: PublicKey;
|
|
798
|
+
stakingProtocol: PublicKey;
|
|
799
|
+
totalHolders: BN;
|
|
800
|
+
totalMinted: BN;
|
|
801
|
+
paused: boolean;
|
|
802
|
+
/** C-01: Timestamp when pending authority transfer was initiated (for 24h timelock) */
|
|
803
|
+
pendingAuthorityActivatedAt: BN;
|
|
804
|
+
}
|
|
805
|
+
/** Parameters for casting a private vote */
|
|
806
|
+
interface CastPrivateVoteParams {
|
|
807
|
+
proposalId: BN;
|
|
808
|
+
/** ElGamal ciphertext for "for" (64 bytes) */
|
|
809
|
+
ctFor: Uint8Array;
|
|
810
|
+
/** ElGamal ciphertext for "against" (64 bytes) */
|
|
811
|
+
ctAgainst: Uint8Array;
|
|
812
|
+
/** ElGamal ciphertext for "abstain" (64 bytes) */
|
|
813
|
+
ctAbstain: Uint8Array;
|
|
814
|
+
/** Vote validity proof (352 bytes) */
|
|
815
|
+
proofData: Uint8Array;
|
|
816
|
+
}
|
|
817
|
+
/** Parameters for enabling private voting on a proposal */
|
|
818
|
+
interface EnablePrivateVotingParams {
|
|
819
|
+
proposalId: BN;
|
|
820
|
+
/** Joint ElGamal public key (Ristretto255 point, 32 bytes) */
|
|
821
|
+
encryptionPubkey: Uint8Array;
|
|
822
|
+
/** Committee member Solana pubkeys */
|
|
823
|
+
decryptionCommittee: PublicKey[];
|
|
824
|
+
committeeSize: number;
|
|
825
|
+
decryptionThreshold: number;
|
|
826
|
+
/** Committee member ElGamal public keys (Ristretto255 points, 32 bytes each) */
|
|
827
|
+
committeeElgamalPubkeys: Uint8Array[];
|
|
828
|
+
}
|
|
829
|
+
/** Parameters for submitting a decryption share */
|
|
830
|
+
interface SubmitDecryptionShareParams {
|
|
831
|
+
proposalId: BN;
|
|
832
|
+
committeeIndex: number;
|
|
833
|
+
/** Partial decryption for "for" (Ristretto255 point, 32 bytes) */
|
|
834
|
+
partialFor: Uint8Array;
|
|
835
|
+
/** Partial decryption for "against" (Ristretto255 point, 32 bytes) */
|
|
836
|
+
partialAgainst: Uint8Array;
|
|
837
|
+
/** Partial decryption for "abstain" (Ristretto255 point, 32 bytes) */
|
|
838
|
+
partialAbstain: Uint8Array;
|
|
839
|
+
/** DLEQ proof challenge (Scalar, 32 bytes) */
|
|
840
|
+
dleqChallenge: Uint8Array;
|
|
841
|
+
/** DLEQ proof response (Scalar, 32 bytes) */
|
|
842
|
+
dleqResponse: Uint8Array;
|
|
843
|
+
}
|
|
844
|
+
/** Parameters for aggregating revealed votes (permissionless) */
|
|
845
|
+
interface AggregateRevealedVotesParams {
|
|
846
|
+
proposalId: BN;
|
|
847
|
+
tallyFor: BN;
|
|
848
|
+
tallyAgainst: BN;
|
|
849
|
+
tallyAbstain: BN;
|
|
850
|
+
/** Lagrange interpolation coefficients (Scalars, 32 bytes each) */
|
|
851
|
+
lagrangeCoefficients: Uint8Array[];
|
|
852
|
+
}
|
|
702
853
|
|
|
703
854
|
/**
|
|
704
855
|
* Governance Client for ViWoApp governance operations
|
|
705
856
|
*
|
|
857
|
+
* Supports both public voting and ZK private voting with Twisted ElGamal
|
|
858
|
+
* encryption on Ristretto255.
|
|
859
|
+
*
|
|
706
860
|
* @example
|
|
707
861
|
* ```typescript
|
|
708
862
|
* const govClient = client.governance;
|
|
@@ -715,8 +869,13 @@ interface HookConfig extends PendingAuthorityFields {
|
|
|
715
869
|
* durationDays: 7,
|
|
716
870
|
* });
|
|
717
871
|
*
|
|
718
|
-
* //
|
|
719
|
-
* await govClient.vote(proposalId, true);
|
|
872
|
+
* // Public vote on a proposal
|
|
873
|
+
* await govClient.vote(proposalId, true);
|
|
874
|
+
*
|
|
875
|
+
* // Private vote (using zk-voting-sdk for encryption)
|
|
876
|
+
* await govClient.buildCastPrivateVoteTransaction({
|
|
877
|
+
* proposalId, ctFor, ctAgainst, ctAbstain, proofData,
|
|
878
|
+
* });
|
|
720
879
|
* ```
|
|
721
880
|
*/
|
|
722
881
|
declare class GovernanceClient {
|
|
@@ -725,7 +884,7 @@ declare class GovernanceClient {
|
|
|
725
884
|
/**
|
|
726
885
|
* Get governance configuration
|
|
727
886
|
*/
|
|
728
|
-
getConfig(): Promise<
|
|
887
|
+
getConfig(): Promise<GovernanceConfig | null>;
|
|
729
888
|
/**
|
|
730
889
|
* Get proposal by ID
|
|
731
890
|
*/
|
|
@@ -744,6 +903,9 @@ declare class GovernanceClient {
|
|
|
744
903
|
hasVoted(proposalId: BN, user?: PublicKey): Promise<boolean>;
|
|
745
904
|
/**
|
|
746
905
|
* Calculate user's voting power
|
|
906
|
+
*
|
|
907
|
+
* @note M-01 fix: 5A boost formula is now `1000 + ((five_a_score * 100) / 1000)`
|
|
908
|
+
* to fix precision loss for small scores.
|
|
747
909
|
*/
|
|
748
910
|
getVotingPower(user?: PublicKey): Promise<BN>;
|
|
749
911
|
/**
|
|
@@ -759,6 +921,9 @@ declare class GovernanceClient {
|
|
|
759
921
|
}>;
|
|
760
922
|
/**
|
|
761
923
|
* Get proposal progress
|
|
924
|
+
*
|
|
925
|
+
* @note C-03: Quorum is now calculated as votesFor + votesAgainst only.
|
|
926
|
+
* Abstains do NOT count toward quorum.
|
|
762
927
|
*/
|
|
763
928
|
getProposalProgress(proposalId: BN): Promise<{
|
|
764
929
|
votesFor: string;
|
|
@@ -774,7 +939,7 @@ declare class GovernanceClient {
|
|
|
774
939
|
*/
|
|
775
940
|
buildCreateProposalTransaction(params: CreateProposalParams): Promise<Transaction>;
|
|
776
941
|
/**
|
|
777
|
-
* Build vote transaction
|
|
942
|
+
* Build vote transaction (public)
|
|
778
943
|
*
|
|
779
944
|
* @note v2.8.0 (C-NEW-01): Voting power parameters (vevcoin_balance, five_a_score, tier)
|
|
780
945
|
* are now read from on-chain state, not passed as parameters. This prevents vote manipulation.
|
|
@@ -788,6 +953,83 @@ declare class GovernanceClient {
|
|
|
788
953
|
* Build execute proposal transaction
|
|
789
954
|
*/
|
|
790
955
|
buildExecuteTransaction(proposalId: BN): Promise<Transaction>;
|
|
956
|
+
/**
|
|
957
|
+
* Get delegation for a user
|
|
958
|
+
*/
|
|
959
|
+
getDelegation(delegator?: PublicKey): Promise<Delegation | null>;
|
|
960
|
+
/**
|
|
961
|
+
* Build delegate votes transaction
|
|
962
|
+
*
|
|
963
|
+
* H-NEW-03: Validates delegation amount against actual veVCoin balance on-chain.
|
|
964
|
+
* The delegated amount must be <= the delegator's veVCoin balance from the staking protocol.
|
|
965
|
+
*
|
|
966
|
+
* @param params - Delegation parameters
|
|
967
|
+
*/
|
|
968
|
+
buildDelegateVotesTransaction(params: DelegateVotesParams): Promise<Transaction>;
|
|
969
|
+
/**
|
|
970
|
+
* Build revoke delegation transaction
|
|
971
|
+
*/
|
|
972
|
+
buildRevokeDelegationTransaction(): Promise<Transaction>;
|
|
973
|
+
/**
|
|
974
|
+
* Build cast private vote transaction
|
|
975
|
+
*
|
|
976
|
+
* Uses Twisted ElGamal encryption on Ristretto255 with compressed sigma proofs.
|
|
977
|
+
* The voter encrypts their choice into 3 ciphertexts (for/against/abstain) and
|
|
978
|
+
* generates a validity proof that exactly one ciphertext encrypts their weight.
|
|
979
|
+
*
|
|
980
|
+
* Use the `zk-voting-sdk` crate to generate ciphertexts and proofs off-chain:
|
|
981
|
+
* ```rust
|
|
982
|
+
* let (ct_for, ct_against, ct_abstain, proof) = encrypt_and_prove(&pubkey, choice, weight);
|
|
983
|
+
* ```
|
|
984
|
+
*
|
|
985
|
+
* @param params - Private vote parameters with ciphertexts and proof
|
|
986
|
+
*/
|
|
987
|
+
buildCastPrivateVoteTransaction(params: CastPrivateVoteParams): Promise<Transaction>;
|
|
988
|
+
/**
|
|
989
|
+
* Build enable private voting transaction
|
|
990
|
+
*
|
|
991
|
+
* Called by the governance authority to enable ZK private voting on a proposal.
|
|
992
|
+
* Requires specifying the decryption committee and their ElGamal public keys.
|
|
993
|
+
*
|
|
994
|
+
* @param params - Private voting configuration
|
|
995
|
+
*/
|
|
996
|
+
buildEnablePrivateVotingTransaction(params: EnablePrivateVotingParams): Promise<Transaction>;
|
|
997
|
+
/**
|
|
998
|
+
* Build submit decryption share transaction
|
|
999
|
+
*
|
|
1000
|
+
* Called by a committee member during the reveal phase.
|
|
1001
|
+
* Each member computes partial decryptions and a DLEQ proof off-chain:
|
|
1002
|
+
* ```rust
|
|
1003
|
+
* let partial = generate_partial_decryption(&secret_share, &pk, &r_for, &r_against, &r_abstain);
|
|
1004
|
+
* ```
|
|
1005
|
+
*
|
|
1006
|
+
* @param params - Decryption share with DLEQ proof
|
|
1007
|
+
*/
|
|
1008
|
+
buildSubmitDecryptionShareTransaction(params: SubmitDecryptionShareParams): Promise<Transaction>;
|
|
1009
|
+
/**
|
|
1010
|
+
* Build aggregate revealed votes transaction (permissionless)
|
|
1011
|
+
*
|
|
1012
|
+
* Anyone can submit the aggregated tally since the on-chain program
|
|
1013
|
+
* cryptographically verifies: tally * H == C_sum - D for each category.
|
|
1014
|
+
* This prevents fabrication of results.
|
|
1015
|
+
*
|
|
1016
|
+
* Use the `zk-voting-sdk` to compute the tally off-chain:
|
|
1017
|
+
* ```rust
|
|
1018
|
+
* let lagrange = compute_lagrange_coefficients(&selected_indices);
|
|
1019
|
+
* let d = combine_partials(&lagrange, &partials);
|
|
1020
|
+
* let tally = recover_tally(&d, &accumulated_c, max_votes).unwrap();
|
|
1021
|
+
* ```
|
|
1022
|
+
*
|
|
1023
|
+
* @param params - Tally values and Lagrange coefficients
|
|
1024
|
+
*/
|
|
1025
|
+
buildAggregateRevealedVotesTransaction(params: AggregateRevealedVotesParams): Promise<Transaction>;
|
|
1026
|
+
/**
|
|
1027
|
+
* Check if authority transfer timelock has elapsed (H-02)
|
|
1028
|
+
*/
|
|
1029
|
+
canAcceptAuthority(): Promise<{
|
|
1030
|
+
canAccept: boolean;
|
|
1031
|
+
reason?: string;
|
|
1032
|
+
}>;
|
|
791
1033
|
}
|
|
792
1034
|
|
|
793
1035
|
/**
|
|
@@ -849,6 +1091,9 @@ declare class RewardsClient {
|
|
|
849
1091
|
}>;
|
|
850
1092
|
/**
|
|
851
1093
|
* Calculate gasless fee for claim
|
|
1094
|
+
*
|
|
1095
|
+
* C-05: Uses ceiling division to prevent fee rounding to zero on small amounts.
|
|
1096
|
+
* Formula: fee = ceil(amount * feeBps / 10000)
|
|
852
1097
|
*/
|
|
853
1098
|
calculateGaslessFee(amount: BN): BN;
|
|
854
1099
|
/**
|
|
@@ -867,6 +1112,9 @@ declare class RewardsClient {
|
|
|
867
1112
|
private hashBytes;
|
|
868
1113
|
/**
|
|
869
1114
|
* Build claim rewards transaction
|
|
1115
|
+
*
|
|
1116
|
+
* H-NEW-02: Merkle proof size is limited to 32 levels (supports 4B+ users).
|
|
1117
|
+
* Proofs exceeding this limit will be rejected on-chain with MerkleProofTooLarge.
|
|
870
1118
|
*/
|
|
871
1119
|
buildClaimTransaction(params: ClaimRewardsParams): Promise<Transaction>;
|
|
872
1120
|
}
|
|
@@ -935,6 +1183,9 @@ declare class ViLinkClient {
|
|
|
935
1183
|
}>;
|
|
936
1184
|
/**
|
|
937
1185
|
* Calculate platform fee for tip
|
|
1186
|
+
*
|
|
1187
|
+
* C-06: Uses ceiling division to prevent fee rounding to zero on small amounts.
|
|
1188
|
+
* Formula: fee = ceil(amount * feeBps / 10000)
|
|
938
1189
|
*/
|
|
939
1190
|
calculateFee(amount: BN): {
|
|
940
1191
|
fee: BN;
|
|
@@ -988,6 +1239,13 @@ declare class ViLinkClient {
|
|
|
988
1239
|
* Build execute tip action transaction
|
|
989
1240
|
* @param creator - The action creator's public key
|
|
990
1241
|
* @param nonce - M-04: The action nonce (NOT timestamp)
|
|
1242
|
+
*
|
|
1243
|
+
* H-05: The on-chain handler validates that the executor's token account has
|
|
1244
|
+
* no active delegation (delegate is None or delegated_amount is 0).
|
|
1245
|
+
* This prevents delegated tokens from being spent without explicit approval.
|
|
1246
|
+
*
|
|
1247
|
+
* C-06: Platform fee uses ceiling division to prevent zero-fee exploitation on
|
|
1248
|
+
* small amounts.
|
|
991
1249
|
*/
|
|
992
1250
|
buildExecuteTipAction(creator: PublicKey, nonce: BN): Promise<Transaction>;
|
|
993
1251
|
/**
|
|
@@ -1033,6 +1291,9 @@ declare class GaslessClient {
|
|
|
1033
1291
|
getSessionKey(user: PublicKey, sessionPubkey: PublicKey): Promise<SessionKey | null>;
|
|
1034
1292
|
/**
|
|
1035
1293
|
* Get user gasless statistics
|
|
1294
|
+
*
|
|
1295
|
+
* H-AUDIT-12: Now includes active_sessions field for per-user session limit tracking.
|
|
1296
|
+
* The protocol enforces a maximum of 5 concurrent active sessions per user.
|
|
1036
1297
|
*/
|
|
1037
1298
|
getUserStats(user?: PublicKey): Promise<UserGaslessStats | null>;
|
|
1038
1299
|
/**
|
|
@@ -1080,6 +1341,9 @@ declare class GaslessClient {
|
|
|
1080
1341
|
createScope(actions: string[]): number;
|
|
1081
1342
|
/**
|
|
1082
1343
|
* Build create session key transaction
|
|
1344
|
+
*
|
|
1345
|
+
* H-AUDIT-12: The protocol enforces a maximum of 5 concurrent active sessions per user.
|
|
1346
|
+
* Creating a session when the limit is reached will fail with MaxSessionsReached error.
|
|
1083
1347
|
*/
|
|
1084
1348
|
buildCreateSessionTransaction(params: CreateSessionParams): Promise<Transaction>;
|
|
1085
1349
|
/**
|
|
@@ -1130,6 +1394,14 @@ declare class IdentityClient {
|
|
|
1130
1394
|
* Get verification level benefits
|
|
1131
1395
|
*/
|
|
1132
1396
|
getVerificationBenefits(level: VerificationLevel): string[];
|
|
1397
|
+
/**
|
|
1398
|
+
* Build subscribe transaction
|
|
1399
|
+
*
|
|
1400
|
+
* C-AUDIT-22: Non-free subscription tiers require actual USDC payment via SPL
|
|
1401
|
+
* transfer_checked. The transaction must include the user's USDC token account,
|
|
1402
|
+
* the USDC mint, and the treasury token account.
|
|
1403
|
+
*/
|
|
1404
|
+
buildSubscribeTransaction(tier: number): Promise<Transaction>;
|
|
1133
1405
|
/**
|
|
1134
1406
|
* Build create identity transaction
|
|
1135
1407
|
*/
|
|
@@ -1190,6 +1462,12 @@ declare class FiveAClient {
|
|
|
1190
1462
|
getMaxVouches(composite: number): number;
|
|
1191
1463
|
/**
|
|
1192
1464
|
* Check if user can vouch for another
|
|
1465
|
+
*
|
|
1466
|
+
* C-08: Mutual vouching is prevented — if the target has already vouched for you,
|
|
1467
|
+
* you cannot vouch for them. This is enforced on-chain via reverse_vouch_record check.
|
|
1468
|
+
*
|
|
1469
|
+
* M-18: Vouches expire after 1 year (MAX_VOUCH_AGE = 365 days). Expired vouches
|
|
1470
|
+
* cannot be evaluated and must be re-created.
|
|
1193
1471
|
*/
|
|
1194
1472
|
canVouchFor(target: PublicKey): Promise<{
|
|
1195
1473
|
canVouch: boolean;
|
|
@@ -1201,6 +1479,12 @@ declare class FiveAClient {
|
|
|
1201
1479
|
getImprovementSuggestions(score: FiveAScore): string[];
|
|
1202
1480
|
/**
|
|
1203
1481
|
* Build vouch transaction
|
|
1482
|
+
*
|
|
1483
|
+
* C-08: On-chain handler requires a reverse_vouch_record account to verify
|
|
1484
|
+
* mutual vouching is not occurring. The transaction must include this PDA.
|
|
1485
|
+
*
|
|
1486
|
+
* M-18: Vouches have a maximum age of 1 year. After that, evaluate_vouch
|
|
1487
|
+
* will reject with VouchExpired error.
|
|
1204
1488
|
*/
|
|
1205
1489
|
buildVouchTransaction(target: PublicKey): Promise<Transaction>;
|
|
1206
1490
|
}
|
|
@@ -1265,6 +1549,9 @@ declare class ContentClient {
|
|
|
1265
1549
|
}>;
|
|
1266
1550
|
/**
|
|
1267
1551
|
* Get content stats
|
|
1552
|
+
*
|
|
1553
|
+
* C-AUDIT-10: Engagement scores can only increase — the on-chain update_engagement
|
|
1554
|
+
* instruction enforces monotonic increase to prevent manipulation.
|
|
1268
1555
|
*/
|
|
1269
1556
|
getContentStats(contentId: Uint8Array): Promise<{
|
|
1270
1557
|
tips: string;
|
|
@@ -1275,6 +1562,9 @@ declare class ContentClient {
|
|
|
1275
1562
|
}>;
|
|
1276
1563
|
/**
|
|
1277
1564
|
* Build create content transaction
|
|
1565
|
+
*
|
|
1566
|
+
* C-AUDIT-11: Energy tiers are validated on-chain (valid range: 1-4).
|
|
1567
|
+
* Tier determines max energy and regen rate.
|
|
1278
1568
|
*/
|
|
1279
1569
|
buildCreateContentTransaction(contentHash: Uint8Array): Promise<Transaction>;
|
|
1280
1570
|
/**
|
|
@@ -1411,6 +1701,10 @@ declare class StakingClient {
|
|
|
1411
1701
|
calculateVeVCoin(amount: BN, lockDuration: number): BN;
|
|
1412
1702
|
/**
|
|
1413
1703
|
* Get tier name
|
|
1704
|
+
*
|
|
1705
|
+
* M-05: The on-chain update_tier instruction will reject no-op tier updates
|
|
1706
|
+
* with TierUnchanged error. Only call updateTier when the user's stake amount
|
|
1707
|
+
* actually qualifies for a different tier.
|
|
1414
1708
|
*/
|
|
1415
1709
|
getTierName(tier: StakingTier): string;
|
|
1416
1710
|
/**
|
|
@@ -1453,4 +1747,4 @@ declare class StakingClient {
|
|
|
1453
1747
|
buildExtendLockTransaction(newDuration: number): Promise<Transaction>;
|
|
1454
1748
|
}
|
|
1455
1749
|
|
|
1456
|
-
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 UserActionStatsExtended, 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 };
|
|
1750
|
+
export { ACTION_SCOPES, ActionType, type AggregateRevealedVotesParams, CONTENT_CONSTANTS, type CastPrivateVoteParams, type ClaimRewardsParams, type ConnectionConfig, ContentClient, type ContentRecord, ContentState, type CreateActionParams, type CreateProposalParams, type CreateSessionParams, type DecryptionShare, type DelegateVotesParams, type Delegation, type EnablePrivateVotingParams, 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 PairTracking, 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, type SubmitDecryptionShareParams, TransactionBuilder, type UserActionStatsExtended, 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, type VeVCoinConfig, VerificationLevel, type ViLinkAction, ViLinkClient, type ViLinkConfig, ViWoClient, ViWoConnection, VoteChoice, type VoteRecord, type VouchRecord, type WalletAdapter, dateToTimestamp, formatVCoin, getCurrentTimestamp, parseVCoin, timestampToDate };
|