@@ -551,14 +551,11 @@ impl PaymasterSidecar {
551551 ///
552552 /// Returns a wrapper containing the process handle and resolved configuration.
553553 pub async fn start ( self ) -> Result < PaymasterSidecarProcess > {
554- let forwarder_address = self . forwarder_address . ok_or ( Error :: ForwarderNotSet ) ?;
555- let chain_id = self . chain_id . ok_or ( Error :: ChainIdNotSet ) ?;
556-
557554 // Build profile and spawn process
558555 let bin =
559556 self . config . program_path . clone ( ) . unwrap_or_else ( || PathBuf :: from ( "paymaster-service" ) ) ;
560557 let bin = resolve_executable ( & bin) ?;
561- let profile = build_paymaster_profile ( & self . config , forwarder_address , chain_id ) ;
558+ let profile = self . build_paymaster_profile ( ) ? ;
562559 let profile_path = write_paymaster_profile ( & profile) ?;
563560
564561 let mut command = Command :: new ( bin) ;
@@ -577,6 +574,54 @@ impl PaymasterSidecar {
577574
578575 Ok ( PaymasterSidecarProcess { process, profile } )
579576 }
577+
578+ fn build_paymaster_profile ( & self ) -> Result < PaymasterProfile > {
579+ let forwarder_address = self . forwarder_address . ok_or ( Error :: ForwarderNotSet ) ?;
580+ let chain_id = self . chain_id . ok_or ( Error :: ChainIdNotSet ) ?;
581+
582+ let chain_id_str = paymaster_chain_id ( chain_id) ;
583+ let price_api_key = self . config . price_api_key . clone ( ) . unwrap_or_default ( ) ;
584+
585+ Ok ( PaymasterProfile {
586+ verbosity : "info" . to_string ( ) ,
587+ prometheus : None ,
588+ rpc : PaymasterRpcProfile { port : self . config . port } ,
589+ forwarder : forwarder_address,
590+ supported_tokens : vec ! [ self . config. eth_token_address, self . config. strk_token_address] ,
591+ max_fee_multiplier : 3.0 ,
592+ provider_fee_overhead : 0.1 ,
593+ estimate_account : PaymasterAccountProfile {
594+ address : self . config . estimate_account_address ,
595+ private_key : self . config . estimate_account_private_key ,
596+ } ,
597+ gas_tank : PaymasterAccountProfile {
598+ address : self . config . gas_tank_address ,
599+ private_key : self . config . gas_tank_private_key ,
600+ } ,
601+ relayers : PaymasterRelayersProfile {
602+ private_key : self . config . relayer_private_key ,
603+ addresses : vec ! [ self . config. relayer_address] ,
604+ min_relayer_balance : Felt :: ZERO ,
605+ lock : PaymasterLockProfile { mode : "seggregated" . to_string ( ) , retry_timeout : 5 } ,
606+ } ,
607+ starknet : PaymasterStarknetProfile {
608+ chain_id : chain_id_str,
609+ endpoint : self . config . rpc_url . clone ( ) ,
610+ timeout : 30 ,
611+ fallbacks : Vec :: new ( ) ,
612+ } ,
613+ price : PaymasterPriceProfile {
614+ provider : "avnu" . to_string ( ) ,
615+ endpoint : Url :: parse ( DEFAULT_AVNU_PRICE_MAINNET_ENDPOINT ) . expect ( "valid url" ) ,
616+ api_key : price_api_key,
617+ } ,
618+ sponsoring : PaymasterSponsoringProfile {
619+ mode : "self" . to_string ( ) ,
620+ api_key : self . config . api_key . clone ( ) ,
621+ sponsor_metadata : Vec :: new ( ) ,
622+ } ,
623+ } )
624+ }
580625}
581626
582627// ============================================================================
@@ -789,55 +834,6 @@ mod ser {
789834 }
790835}
791836
792- fn build_paymaster_profile (
793- config : & PaymasterConfig ,
794- forwarder_address : ContractAddress ,
795- chain_id : ChainId ,
796- ) -> PaymasterProfile {
797- let chain_id_str = paymaster_chain_id ( chain_id) ;
798- let price_api_key = config. price_api_key . clone ( ) . unwrap_or_default ( ) ;
799-
800- PaymasterProfile {
801- verbosity : "info" . to_string ( ) ,
802- prometheus : None ,
803- rpc : PaymasterRpcProfile { port : config. port } ,
804- forwarder : forwarder_address,
805- supported_tokens : vec ! [ config. eth_token_address, config. strk_token_address] ,
806- max_fee_multiplier : 3.0 ,
807- provider_fee_overhead : 0.1 ,
808- estimate_account : PaymasterAccountProfile {
809- address : config. estimate_account_address ,
810- private_key : config. estimate_account_private_key ,
811- } ,
812- gas_tank : PaymasterAccountProfile {
813- address : config. gas_tank_address ,
814- private_key : config. gas_tank_private_key ,
815- } ,
816- relayers : PaymasterRelayersProfile {
817- private_key : config. relayer_private_key ,
818- addresses : vec ! [ config. relayer_address] ,
819- min_relayer_balance : Felt :: ZERO ,
820- lock : PaymasterLockProfile { mode : "seggregated" . to_string ( ) , retry_timeout : 5 } ,
821- } ,
822- starknet : PaymasterStarknetProfile {
823- chain_id : chain_id_str,
824- endpoint : config. rpc_url . clone ( ) ,
825- timeout : 30 ,
826- fallbacks : Vec :: new ( ) ,
827- } ,
828- price : PaymasterPriceProfile {
829- provider : "avnu" . to_string ( ) ,
830- endpoint : Url :: parse ( DEFAULT_AVNU_PRICE_MAINNET_ENDPOINT ) . expect ( "valid url" ) ,
831- api_key : price_api_key,
832- } ,
833- sponsoring : PaymasterSponsoringProfile {
834- mode : "self" . to_string ( ) ,
835- api_key : config. api_key . clone ( ) ,
836- sponsor_metadata : Vec :: new ( ) ,
837- } ,
838- }
839- }
840-
841837fn write_paymaster_profile ( profile : & PaymasterProfile ) -> Result < PathBuf > {
842838 let payload = serde_json:: to_string_pretty ( profile) . map_err ( Error :: ProfileSerialize ) ?;
843839 let timestamp = SystemTime :: now ( )
0 commit comments