@@ -264,9 +264,11 @@ pub fn update_session_with_contracts_analyses(
264264 for batch in deployment. plan . batches . iter ( ) {
265265 for transaction in batch. transactions . iter ( ) {
266266 match transaction {
267- TransactionSpecification :: EmulatedContractCall ( _)
268- | TransactionSpecification :: ContractCall ( _)
269- | TransactionSpecification :: ContractPublish ( _) => { }
267+ TransactionSpecification :: ContractCall ( _)
268+ | TransactionSpecification :: ContractPublish ( _) => unreachable ! ( ) ,
269+ TransactionSpecification :: EmulatedContractCall ( _) => {
270+ /* Do nothing, as a emulated-contract-call would not impact subsequent emulated-contract-publish */
271+ }
270272 TransactionSpecification :: EmulatedContractPublish ( tx) => {
271273 let mut diagnostics = vec ! [ ] ;
272274
@@ -878,7 +880,7 @@ pub fn generate_default_deployment(
878880 }
879881
880882 // Avoid listing requirements as deployment transactions to the deployment specification on Devnet / Testnet / Mainnet
881- if let StacksNetwork :: Simnet = network {
883+ if network. is_simnet ( ) {
882884 let ordered_contracts_ids =
883885 match ASTDependencyDetector :: order_contracts ( & requirements_deps) {
884886 Ok ( ordered_contracts) => ordered_contracts,
@@ -896,7 +898,7 @@ pub fn generate_default_deployment(
896898 }
897899
898900 let mut contracts = HashMap :: new ( ) ;
899-
901+ let mut contracts_sources = HashMap :: new ( ) ;
900902 for ( name, config) in manifest. contracts . iter ( ) {
901903 let contract_name = match ContractName :: try_from ( name. to_string ( ) ) {
902904 Ok ( res) => res,
@@ -920,7 +922,7 @@ pub fn generate_default_deployment(
920922 None => default_deployer,
921923 } ;
922924
923- let emulated_sender = match PrincipalData :: parse_standard_principal ( & deployer. address ) {
925+ let sender = match PrincipalData :: parse_standard_principal ( & deployer. address ) {
924926 Ok ( res) => res,
925927 Err ( _) => {
926928 return Err ( format ! (
@@ -942,34 +944,45 @@ pub fn generate_default_deployment(
942944 }
943945 } ;
944946
945- let contract = EmulatedContractPublishSpecification {
946- contract_name,
947- emulated_sender,
948- source,
949- relative_path : config. path . clone ( ) ,
950- } ;
947+ let contract_id = QualifiedContractIdentifier :: new ( sender. clone ( ) , contract_name. clone ( ) ) ;
951948
952- let contract_id = QualifiedContractIdentifier :: new (
953- contract. emulated_sender . clone ( ) ,
954- contract. contract_name . clone ( ) ,
955- ) ;
949+ contracts_sources. insert ( contract_id. clone ( ) , source. clone ( ) ) ;
950+
951+ let contract_spec = if network. is_simnet ( ) {
952+ TransactionSpecification :: EmulatedContractPublish (
953+ EmulatedContractPublishSpecification {
954+ contract_name,
955+ emulated_sender : sender,
956+ source,
957+ relative_path : config. path . clone ( ) ,
958+ } ,
959+ )
960+ } else {
961+ TransactionSpecification :: ContractPublish ( ContractPublishSpecification {
962+ contract_name,
963+ expected_sender : sender,
964+ relative_path : config. path . clone ( ) ,
965+ cost : deployment_fee_rate
966+ . saturating_mul ( source. as_bytes ( ) . len ( ) . try_into ( ) . unwrap ( ) ) ,
967+ source,
968+ } )
969+ } ;
956970
957- contracts. insert ( contract_id, contract ) ;
971+ contracts. insert ( contract_id, contract_spec ) ;
958972 }
959973
960974 let session = Session :: new ( settings) ;
961975
962976 let mut contract_asts = HashMap :: new ( ) ;
963977 let mut contract_diags = HashMap :: new ( ) ;
964978
965- for ( contract_id, contract) in contracts. iter ( ) {
966- let ( ast, diags, _) = session. interpreter . build_ast (
967- contract_id. clone ( ) ,
968- contract. source . clone ( ) ,
969- parser_version,
970- ) ;
979+ for ( contract_id, source) in contracts_sources. into_iter ( ) {
980+ let ( ast, diags, _) =
981+ session
982+ . interpreter
983+ . build_ast ( contract_id. clone ( ) , source, parser_version) ;
971984 contract_asts. insert ( contract_id. clone ( ) , ast) ;
972- contract_diags. insert ( contract_id. clone ( ) , diags) ;
985+ contract_diags. insert ( contract_id, diags) ;
973986 }
974987
975988 let dependencies =
@@ -1000,26 +1013,25 @@ pub fn generate_default_deployment(
10001013 if requirements_asts. contains_key ( & contract_id) {
10011014 continue ;
10021015 }
1003- let data = contracts
1016+ let tx = contracts
10041017 . remove ( & contract_id)
10051018 . expect ( "unable to retrieve contract" ) ;
1006- contracts_map. insert (
1007- contract_id. clone ( ) ,
1008- ( data. source . clone ( ) , data. relative_path . clone ( ) ) ,
1009- ) ;
1010- let tx = if let StacksNetwork :: Simnet = network {
1011- TransactionSpecification :: EmulatedContractPublish ( data)
1012- } else {
1013- TransactionSpecification :: ContractPublish ( ContractPublishSpecification {
1014- contract_name : data. contract_name . clone ( ) ,
1015- expected_sender : data. emulated_sender . clone ( ) ,
1016- relative_path : data. relative_path . clone ( ) ,
1017- source : data. source . clone ( ) ,
1018- cost : deployment_fee_rate
1019- . saturating_mul ( data. source . as_bytes ( ) . len ( ) . try_into ( ) . unwrap ( ) ) ,
1020- } )
1021- } ;
10221019
1020+ match tx {
1021+ TransactionSpecification :: EmulatedContractPublish ( ref data) => {
1022+ contracts_map. insert (
1023+ contract_id. clone ( ) ,
1024+ ( data. source . clone ( ) , data. relative_path . clone ( ) ) ,
1025+ ) ;
1026+ }
1027+ TransactionSpecification :: ContractPublish ( ref data) => {
1028+ contracts_map. insert (
1029+ contract_id. clone ( ) ,
1030+ ( data. source . clone ( ) , data. relative_path . clone ( ) ) ,
1031+ ) ;
1032+ }
1033+ _ => unreachable ! ( ) ,
1034+ }
10231035 transactions. push ( tx) ;
10241036 }
10251037
@@ -1034,7 +1046,7 @@ pub fn generate_default_deployment(
10341046 }
10351047
10361048 let mut wallets = vec ! [ ] ;
1037- if let StacksNetwork :: Simnet = network {
1049+ if network. is_simnet ( ) {
10381050 for ( name, account) in chain_config. accounts . into_iter ( ) {
10391051 let address = match PrincipalData :: parse_standard_principal ( & account. address ) {
10401052 Ok ( res) => res,
@@ -1064,7 +1076,7 @@ pub fn generate_default_deployment(
10641076 name,
10651077 node,
10661078 network : network. clone ( ) ,
1067- genesis : if let StacksNetwork :: Simnet = network {
1079+ genesis : if network. is_simnet ( ) {
10681080 Some ( GenesisSpecification {
10691081 wallets,
10701082 contracts : manifest. project . boot_contracts . clone ( ) ,
0 commit comments