@@ -92,31 +92,18 @@ impl CodeCid {
92
92
pub fn get_cid_type ( rt : & impl Runtime , addr : U256 ) -> CodeCid {
93
93
let addr: EthAddress = addr. into ( ) ;
94
94
95
- if let Ok ( addr) = addr. try_into ( ) {
96
- rt. resolve_address ( & addr)
97
- . and_then ( |id| {
98
- rt. get_actor_code_cid ( & id) . map ( |cid| {
99
- let code_cid = rt
100
- . resolve_builtin_actor_type ( & cid)
101
- . map ( |t| {
102
- match t {
103
- Type :: Account => CodeCid :: Account ,
104
- // TODO part of current account abstraction hack where emryos are accounts
105
- Type :: Embryo => CodeCid :: Account ,
106
- Type :: EVM => CodeCid :: EVM ( addr) ,
107
- // remaining builtin actors are native
108
- _ => CodeCid :: Native ( cid) ,
109
- }
110
- // not a builtin actor, so it is probably a native actor
111
- } )
112
- . unwrap_or ( CodeCid :: Native ( cid) ) ;
113
- code_cid
114
- } )
115
- } )
116
- . unwrap_or ( CodeCid :: NotFound )
117
- } else {
118
- CodeCid :: NotFound
119
- }
95
+ addr. try_into ( )
96
+ . ok ( ) // into filecoin address
97
+ . and_then ( |addr| rt. resolve_address ( & addr) ) // resolve actor id
98
+ . and_then ( |id| rt. get_actor_code_cid ( & id) . map ( |cid| ( id, cid) ) ) // resolve code cid
99
+ . map ( |( id, cid) | match rt. resolve_builtin_actor_type ( & cid) {
100
+ // TODO part of current account abstraction hack where embryos are accounts
101
+ Some ( Type :: Account | Type :: Embryo ) => CodeCid :: Account ,
102
+ Some ( Type :: EVM ) => CodeCid :: EVM ( Address :: new_id ( id) ) ,
103
+ // remaining builtin actors are native
104
+ _ => CodeCid :: Native ( cid) ,
105
+ } )
106
+ . unwrap_or ( CodeCid :: NotFound )
120
107
}
121
108
122
109
pub fn get_evm_bytecode ( rt : & impl Runtime , addr : & Address ) -> Result < Vec < u8 > , StatusCode > {
0 commit comments