This repository was archived by the owner on Mar 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +46
-1
lines changed Expand file tree Collapse file tree 5 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ export type ConfigSchema = {
3131 minSelfStake : number ;
3232 commission : number ;
3333 unclaimedEraThreshold : number ;
34+ enableKYC : boolean ;
3435 } ;
3536 cron : {
3637 monitor : string ;
Original file line number Diff line number Diff line change 88 checkConnectionTime ,
99 checkIdentity ,
1010 checkKusamaRank ,
11+ checkKYC ,
1112 checkLatestClientVersion ,
1213 checkOffline ,
1314 checkOnline ,
@@ -129,6 +130,14 @@ export const checkCandidate = async (
129130 logger . info ( `${ candidate . name } beefy keys not valid` , constraintsLabel ) ;
130131 }
131132
133+ const kycValid =
134+ constraints . config ?. constraints ?. enableKYC == true
135+ ? await checkKYC ( candidate )
136+ : true ;
137+ if ( ! kycValid ) {
138+ logger . info ( `${ candidate . name } kyc not valid` , constraintsLabel ) ;
139+ }
140+
132141 valid =
133142 onlineValid &&
134143 validateValid &&
@@ -142,7 +151,8 @@ export const checkCandidate = async (
142151 blockedValid &&
143152 kusamaValid &&
144153 providerValid &&
145- beefyValid ;
154+ beefyValid &&
155+ kycValid ;
146156
147157 await setValid ( candidate , valid ) ;
148158
Original file line number Diff line number Diff line change 88 setConnectionTimeInvalidity ,
99 setIdentityInvalidity ,
1010 setKusamaRankInvalidity ,
11+ setKYCInvalidity ,
1112 setLatestClientReleaseValidity ,
1213 setOfflineAccumulatedInvalidity ,
1314 setOnlineValidity ,
@@ -434,3 +435,20 @@ export const checkBeefyKeys = async (
434435 throw new Error ( "could not make validity check" ) ;
435436 }
436437} ;
438+
439+ export const checkKYC = async ( candidate : Candidate ) : Promise < boolean > => {
440+ try {
441+ const isKYC = await queries . isKYC ( candidate . stash ) ;
442+ if ( isKYC ) {
443+ const invalidityString = `${ candidate . name } is not KYC` ;
444+ await setKYCInvalidity ( candidate , false , invalidityString ) ;
445+ return false ;
446+ } else {
447+ await setKYCInvalidity ( candidate , true ) ;
448+ return true ;
449+ }
450+ } catch ( e ) {
451+ logger . warn ( `Error trying to get kyc...` , constraintsLabel ) ;
452+ throw new Error ( "could not make validity check" ) ;
453+ }
454+ } ;
Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ export enum InvalidityReasonType {
8888 KUSAMA_RANK = "KUSAMA_RANK" ,
8989 PROVIDER = "PROVIDER" ,
9090 BEEFY = "BEEFY" ,
91+ KYC = "KYC" ,
9192}
9293
9394export interface InvalidityReason {
Original file line number Diff line number Diff line change @@ -1053,6 +1053,21 @@ export const setBeefyKeysInvalidity = async (
10531053 ) ;
10541054} ;
10551055
1056+ export const setKYCInvalidity = async (
1057+ candidate : Candidate ,
1058+ isValid : boolean ,
1059+ message ?: string ,
1060+ ) : Promise < void > => {
1061+ const invalidityMessage = message ? message : `${ candidate . name } is not KYC` ;
1062+ setCandidateInvalidity (
1063+ candidate ,
1064+ InvalidityReasonType . KYC ,
1065+ isValid ,
1066+ invalidityMessage ,
1067+ true ,
1068+ ) ;
1069+ } ;
1070+
10561071// Sets valid boolean for node
10571072export const setValid = async (
10581073 candidate : Candidate ,
You can’t perform that action at this time.
0 commit comments