@@ -132,28 +132,33 @@ impl NetworkRunnable for Cmd {
132132 if self . fee . build_only {
133133 return Ok ( TxnResult :: Txn ( tx_without_preflight) ) ;
134134 }
135- let code_key =
136- xdr:: LedgerKey :: ContractCode ( xdr:: LedgerKeyContractCode { hash : hash. clone ( ) } ) ;
137- let contract_data = client. get_ledger_entries ( & [ code_key] ) . await ?;
138- // Skip install if the contract is already installed, and the contract has an extension version that isn't V0.
139- // In protocol 21 extension V1 was added that stores additional information about a contract making execution
140- // of the contract cheaper. So if folks want to reinstall we should let them which is why the install will still
141- // go ahead if the contract has a V0 extension.
142- if let Some ( entries) = contract_data. entries {
143- if let Some ( entry_result) = entries. first ( ) {
144- let entry: LedgerEntryData =
145- LedgerEntryData :: from_xdr_base64 ( & entry_result. xdr , Limits :: none ( ) ) ?;
135+ // Don't check whether the contract is already installed when the user
136+ // has requested to perform simulation only and is hoping to get a
137+ // transaction back.
138+ if !self . fee . sim_only {
139+ let code_key =
140+ xdr:: LedgerKey :: ContractCode ( xdr:: LedgerKeyContractCode { hash : hash. clone ( ) } ) ;
141+ let contract_data = client. get_ledger_entries ( & [ code_key] ) . await ?;
142+ // Skip install if the contract is already installed, and the contract has an extension version that isn't V0.
143+ // In protocol 21 extension V1 was added that stores additional information about a contract making execution
144+ // of the contract cheaper. So if folks want to reinstall we should let them which is why the install will still
145+ // go ahead if the contract has a V0 extension.
146+ if let Some ( entries) = contract_data. entries {
147+ if let Some ( entry_result) = entries. first ( ) {
148+ let entry: LedgerEntryData =
149+ LedgerEntryData :: from_xdr_base64 ( & entry_result. xdr , Limits :: none ( ) ) ?;
146150
147- match & entry {
148- LedgerEntryData :: ContractCode ( code) => {
149- // Skip reupload if this isn't V0 because V1 extension already
150- // exists.
151- if code. ext . ne ( & ContractCodeEntryExt :: V0 ) {
152- return Ok ( TxnResult :: Res ( hash) ) ;
151+ match & entry {
152+ LedgerEntryData :: ContractCode ( code) => {
153+ // Skip reupload if this isn't V0 because V1 extension already
154+ // exists.
155+ if code. ext . ne ( & ContractCodeEntryExt :: V0 ) {
156+ return Ok ( TxnResult :: Res ( hash) ) ;
157+ }
158+ }
159+ _ => {
160+ tracing:: warn!( "Entry retrieved should be of type ContractCode" ) ;
153161 }
154- }
155- _ => {
156- tracing:: warn!( "Entry retrieved should be of type ContractCode" ) ;
157162 }
158163 }
159164 }
0 commit comments