@@ -61,7 +61,7 @@ impl From<AddressError> for AccountIdError {
6161impl Display for AccountId {
6262 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
6363 let addr = Address ( self . 0 . as_slice ( ) . try_into ( ) . unwrap ( ) ) ;
64- write ! ( f, "{:? }" , addr)
64+ write ! ( f, "{}" , addr)
6565 }
6666}
6767
@@ -80,28 +80,13 @@ impl serde::Serialize for AccountId {
8080 }
8181}
8282
83- // Helper to parse both formats - we need this for backwards state compatibility chains <= 0.3.2
84- // TODO: This can be removed in the future with a new devnet
85- #[ derive( Debug , serde:: Serialize , serde:: Deserialize ) ]
86- #[ serde( untagged, crate = "::cosmwasm_schema::serde" ) ]
87- enum StringOrBytes {
88- String ( String ) ,
89- Vec ( Vec < u8 > ) ,
90- }
91-
9283impl < ' de > serde:: Deserialize < ' de > for AccountId {
9384 fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
9485 where
9586 D : serde:: Deserializer < ' de > ,
9687 {
97- match StringOrBytes :: deserialize ( deserializer) ? {
98- StringOrBytes :: String ( s) => {
99- AccountId :: parse_string ( & s) . map_err ( |e| serde:: de:: Error :: custom ( e. to_string ( ) ) )
100- }
101- StringOrBytes :: Vec ( raw) => {
102- AccountId :: new ( & raw ) . map_err ( |e| serde:: de:: Error :: custom ( e. to_string ( ) ) )
103- }
104- }
88+ let s = String :: deserialize ( deserializer) ?;
89+ AccountId :: parse_string ( & s) . map_err ( |e| serde:: de:: Error :: custom ( e. to_string ( ) ) )
10590 }
10691}
10792
@@ -224,19 +209,17 @@ mod tests {
224209 let as_string = to_json_binary ( & id. to_string ( ) ) . unwrap ( ) ;
225210 assert ! ( as_string. starts_with( br#""0x"# ) ) ;
226211
227- let as_raw = to_json_binary ( & raw ) . unwrap ( ) ;
228- assert ! ( as_raw. starts_with( b"[42,42," ) ) ;
229-
230- // ensure we can decode back to the same value from raw
231- let parsed: AccountId = from_json ( & as_raw) . unwrap ( ) ;
232- assert_eq ! ( parsed, id) ;
233-
234212 // ensure we can decode back to the same value from string
235213 let parsed: AccountId = from_json ( & as_string) . unwrap ( ) ;
236214 assert_eq ! ( parsed, id) ;
237215
238216 // ensure we encode as string
239217 let encoded = to_json_binary ( & id) . unwrap ( ) ;
240218 assert_eq ! ( encoded, as_string) ;
219+
220+ // we no longer accept raw
221+ let as_raw = to_json_binary ( & raw ) . unwrap ( ) ;
222+ assert ! ( as_raw. starts_with( b"[42,42," ) ) ;
223+ let _ = from_json :: < AccountId > ( & as_raw) . unwrap_err ( ) ;
241224 }
242225}
0 commit comments