@@ -12,6 +12,7 @@ use std::collections::{BTreeMap, BTreeSet};
1212use namada_core:: address:: Address ;
1313use namada_core:: borsh:: BorshDeserialize ;
1414use namada_core:: collections:: HashSet ;
15+ use namada_core:: hash:: Hash ;
1516use namada_core:: storage:: Epoch ;
1617use namada_core:: token;
1718use namada_state:: {
@@ -169,17 +170,29 @@ where
169170 let proposal_type: Option < ProposalType > =
170171 storage. read ( & proposal_type_key) ?;
171172
172- let proposal = proposal_type. map ( |proposal_type| StorageProposal {
173+ let proposal_type = if let Some ( proposal_type) = proposal_type {
174+ if let ProposalType :: DefaultWithWasm ( _) = proposal_type {
175+ let proposal_code_key = governance_keys:: get_proposal_code_key ( id) ;
176+ let proposal_code: Vec < u8 > =
177+ storage. read ( & proposal_code_key) ?. unwrap_or_default ( ) ;
178+ let proposal_code_hash = Hash :: sha256 ( proposal_code) ;
179+ ProposalType :: DefaultWithWasm ( proposal_code_hash)
180+ } else {
181+ proposal_type
182+ }
183+ } else {
184+ return Ok ( None ) ;
185+ } ;
186+
187+ Ok ( Some ( StorageProposal {
173188 id,
174189 content : content. unwrap ( ) ,
175190 author : author. unwrap ( ) ,
176191 r#type : proposal_type,
177192 voting_start_epoch : voting_start_epoch. unwrap ( ) ,
178193 voting_end_epoch : voting_end_epoch. unwrap ( ) ,
179194 activation_epoch : activation_epoch. unwrap ( ) ,
180- } ) ;
181-
182- Ok ( proposal)
195+ } ) )
183196}
184197
185198/// Query all the votes for a proposal_id
0 commit comments