@@ -64,6 +64,7 @@ import {
6464 WriteReportRequestSchema ,
6565} from '@cre/generated/capabilities/blockchain/solana/v1alpha/client_pb'
6666import {
67+ type CapabilityRestrictionJson ,
6768 type ReportResponse ,
6869 type ReportResponseJson ,
6970 ReportResponseSchema ,
@@ -629,3 +630,136 @@ class ClientLogTrigger implements Trigger<Log, Log> {
629630 return rawOutput
630631 }
631632}
633+ export class ClientRestrictor {
634+ constructor ( private readonly ChainSelector : bigint ) { }
635+
636+ limitGetAccountInfoWithOpts ( maxCalls : number ) : CapabilityRestrictionJson {
637+ // Include all labels in capability ID for routing when specified
638+ const capabilityId = `${ ClientCapability . CAPABILITY_NAME } :ChainSelector:${ this . ChainSelector } @${ ClientCapability . CAPABILITY_VERSION } `
639+
640+ return {
641+ method : {
642+ id : capabilityId ,
643+ method : 'GetAccountInfoWithOpts' ,
644+ maxCalls,
645+ } ,
646+ }
647+ }
648+
649+ limitGetBalance ( maxCalls : number ) : CapabilityRestrictionJson {
650+ // Include all labels in capability ID for routing when specified
651+ const capabilityId = `${ ClientCapability . CAPABILITY_NAME } :ChainSelector:${ this . ChainSelector } @${ ClientCapability . CAPABILITY_VERSION } `
652+
653+ return {
654+ method : {
655+ id : capabilityId ,
656+ method : 'GetBalance' ,
657+ maxCalls,
658+ } ,
659+ }
660+ }
661+
662+ limitGetBlock ( maxCalls : number ) : CapabilityRestrictionJson {
663+ // Include all labels in capability ID for routing when specified
664+ const capabilityId = `${ ClientCapability . CAPABILITY_NAME } :ChainSelector:${ this . ChainSelector } @${ ClientCapability . CAPABILITY_VERSION } `
665+
666+ return {
667+ method : {
668+ id : capabilityId ,
669+ method : 'GetBlock' ,
670+ maxCalls,
671+ } ,
672+ }
673+ }
674+
675+ limitGetFeeForMessage ( maxCalls : number ) : CapabilityRestrictionJson {
676+ // Include all labels in capability ID for routing when specified
677+ const capabilityId = `${ ClientCapability . CAPABILITY_NAME } :ChainSelector:${ this . ChainSelector } @${ ClientCapability . CAPABILITY_VERSION } `
678+
679+ return {
680+ method : {
681+ id : capabilityId ,
682+ method : 'GetFeeForMessage' ,
683+ maxCalls,
684+ } ,
685+ }
686+ }
687+
688+ limitGetMultipleAccountsWithOpts ( maxCalls : number ) : CapabilityRestrictionJson {
689+ // Include all labels in capability ID for routing when specified
690+ const capabilityId = `${ ClientCapability . CAPABILITY_NAME } :ChainSelector:${ this . ChainSelector } @${ ClientCapability . CAPABILITY_VERSION } `
691+
692+ return {
693+ method : {
694+ id : capabilityId ,
695+ method : 'GetMultipleAccountsWithOpts' ,
696+ maxCalls,
697+ } ,
698+ }
699+ }
700+
701+ limitGetProgramAccounts ( maxCalls : number ) : CapabilityRestrictionJson {
702+ // Include all labels in capability ID for routing when specified
703+ const capabilityId = `${ ClientCapability . CAPABILITY_NAME } :ChainSelector:${ this . ChainSelector } @${ ClientCapability . CAPABILITY_VERSION } `
704+
705+ return {
706+ method : {
707+ id : capabilityId ,
708+ method : 'GetProgramAccounts' ,
709+ maxCalls,
710+ } ,
711+ }
712+ }
713+
714+ limitGetSignatureStatuses ( maxCalls : number ) : CapabilityRestrictionJson {
715+ // Include all labels in capability ID for routing when specified
716+ const capabilityId = `${ ClientCapability . CAPABILITY_NAME } :ChainSelector:${ this . ChainSelector } @${ ClientCapability . CAPABILITY_VERSION } `
717+
718+ return {
719+ method : {
720+ id : capabilityId ,
721+ method : 'GetSignatureStatuses' ,
722+ maxCalls,
723+ } ,
724+ }
725+ }
726+
727+ limitGetSlotHeight ( maxCalls : number ) : CapabilityRestrictionJson {
728+ // Include all labels in capability ID for routing when specified
729+ const capabilityId = `${ ClientCapability . CAPABILITY_NAME } :ChainSelector:${ this . ChainSelector } @${ ClientCapability . CAPABILITY_VERSION } `
730+
731+ return {
732+ method : {
733+ id : capabilityId ,
734+ method : 'GetSlotHeight' ,
735+ maxCalls,
736+ } ,
737+ }
738+ }
739+
740+ limitGetTransaction ( maxCalls : number ) : CapabilityRestrictionJson {
741+ // Include all labels in capability ID for routing when specified
742+ const capabilityId = `${ ClientCapability . CAPABILITY_NAME } :ChainSelector:${ this . ChainSelector } @${ ClientCapability . CAPABILITY_VERSION } `
743+
744+ return {
745+ method : {
746+ id : capabilityId ,
747+ method : 'GetTransaction' ,
748+ maxCalls,
749+ } ,
750+ }
751+ }
752+
753+ limitWriteReport ( maxCalls : number ) : CapabilityRestrictionJson {
754+ // Include all labels in capability ID for routing when specified
755+ const capabilityId = `${ ClientCapability . CAPABILITY_NAME } :ChainSelector:${ this . ChainSelector } @${ ClientCapability . CAPABILITY_VERSION } `
756+
757+ return {
758+ method : {
759+ id : capabilityId ,
760+ method : 'WriteReport' ,
761+ maxCalls,
762+ } ,
763+ }
764+ }
765+ }
0 commit comments