2727
2828@dataclass
2929class Deployment :
30- name : str # internal: the name for the deployment
30+ name : str # internal: the name for the deployment
3131 contract : str # internal: the name of the contract to deploy
3232 network : str # internal: the name of the network to deploy to
3333 deployer_key : str # config: the name of the key to use for deployment
@@ -402,7 +402,7 @@ def add_profile(profile: str, network_name: str):
402402 toml .dump (data , toml_file )
403403
404404 @staticmethod
405- def add_contract (project_root : str , template : str , name : str , branch : str ) -> Contract :
405+ def add_contract (project_root : str , template : str , name : str , branch : Optional [ str ] ) -> Optional [ Contract ] :
406406
407407 contract_path = os .path .join (project_root , 'contracts' , name )
408408
@@ -425,9 +425,11 @@ def add_contract(project_root: str, template: str, name: str, branch: str) -> Co
425425 contract_template_path = os .path .join (temp_clone_path , "contracts" , template )
426426 if not os .path .isdir (contract_template_path ):
427427 print (f"Unknown template { template } : expecting one of { set (available_templates )} " )
428- return
428+ return None
429429 print ("Downloading template...complete" )
430430
431+ name_underscored = name .replace ("-" , "_" )
432+
431433 # process all the files as part of the template
432434 print ("Rendering template..." )
433435 for root , _ , files in os .walk (contract_template_path ):
@@ -440,12 +442,11 @@ def add_contract(project_root: str, template: str, name: str, branch: str) -> Co
440442 with open (file_path , "r" , encoding = "utf8" ) as input_file :
441443 with open (output_filepath , "w" , encoding = "utf8" ) as output_file :
442444 contents = input_file .read ()
443-
444445 # replace the templating parameters here
445446 if file_path .endswith (".toml" ):
446447 contents = contents .replace ("<<NAME>>" , name )
447448 else :
448- contents = contents .replace ("<<NAME>>" , name . replace ( "-" , "_" ) )
449+ contents = contents .replace ("<<NAME>>" , name_underscored )
449450
450451 output_file .write (contents )
451452 print ("Rendering template...complete" )
0 commit comments