1+ use crate :: log:: { setup_solana_logging, turn_off_solana_logging} ;
12use crate :: trident_svm:: TridentSVM ;
23use crate :: types:: trident_account:: TridentAccountSharedData ;
34use crate :: types:: trident_entrypoint:: TridentEntrypoint ;
@@ -7,6 +8,7 @@ use crate::types::trident_program::TridentProgram;
78pub struct TridentSVMConfig {
89 syscalls_v1 : bool ,
910 syscalls_v2 : bool ,
11+ cli_logs : bool , // TODO, add better debbug levels
1012 program_entrypoints : Vec < TridentEntrypoint > ,
1113 program_binaries : Vec < TridentProgram > ,
1214 permanent_accounts : Vec < TridentAccountSharedData > ,
@@ -24,32 +26,37 @@ impl TridentSVMBuilder {
2426 }
2527 }
2628
27- pub fn with_syscalls_v1 ( mut self ) -> Self {
29+ pub fn with_syscalls_v1 ( & mut self ) -> & Self {
2830 self . config . syscalls_v1 = true ;
2931 self
3032 }
3133
32- pub fn with_syscalls_v2 ( mut self ) -> Self {
34+ pub fn with_syscalls_v2 ( & mut self ) -> & Self {
3335 self . config . syscalls_v2 = true ;
3436 self
3537 }
3638
37- pub fn with_program_entries ( mut self , entries : Vec < TridentEntrypoint > ) -> Self {
39+ pub fn with_program_entries ( & mut self , entries : Vec < TridentEntrypoint > ) -> & Self {
3840 self . config . program_entrypoints = entries;
3941 self
4042 }
4143
42- pub fn with_sbf_programs ( mut self , programs : Vec < TridentProgram > ) -> Self {
44+ pub fn with_sbf_programs ( & mut self , programs : Vec < TridentProgram > ) -> & Self {
4345 self . config . program_binaries = programs;
4446 self
4547 }
4648
47- pub fn with_permanent_accounts ( mut self , accounts : Vec < TridentAccountSharedData > ) -> Self {
49+ pub fn with_permanent_accounts ( & mut self , accounts : Vec < TridentAccountSharedData > ) -> & Self {
4850 self . config . permanent_accounts = accounts;
4951 self
5052 }
5153
52- pub fn build ( self ) -> TridentSVM {
54+ pub fn with_cli_logs ( & mut self ) -> & Self {
55+ self . config . cli_logs = true ;
56+ self
57+ }
58+
59+ pub fn build ( & self ) -> TridentSVM {
5360 let mut svm = TridentSVM :: default ( ) ;
5461
5562 if self . config . syscalls_v1 {
@@ -59,15 +66,21 @@ impl TridentSVMBuilder {
5966 svm. initialize_syscalls_v2 ( ) ;
6067 }
6168
62- for entry in self . config . program_entrypoints {
63- svm. deploy_entrypoint_program ( & entry) ;
69+ if self . config . cli_logs {
70+ setup_solana_logging ( ) ;
71+ } else {
72+ turn_off_solana_logging ( ) ;
73+ }
74+
75+ for entry in & self . config . program_entrypoints {
76+ svm. deploy_entrypoint_program ( entry) ;
6477 }
6578
66- for program in self . config . program_binaries {
67- svm. deploy_binary_program ( & program) ;
79+ for program in & self . config . program_binaries {
80+ svm. deploy_binary_program ( program) ;
6881 }
6982
70- for account in self . config . permanent_accounts {
83+ for account in & self . config . permanent_accounts {
7184 svm. accounts
7285 . set_permanent_account ( & account. address , & account. account ) ;
7386 }
0 commit comments