Skip to content

Commit

Permalink
remove unused types in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyan-dfinity committed Jun 25, 2024
1 parent 6ed5d95 commit 625483a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rust/candid_parser/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ pub fn get_metadata(env: &TypeEnv, serv: &Option<Type>) -> Option<String> {
TypeInner::Service(_) => serv,
_ => unreachable!(),
};
Some(candid::pretty::candid::compile(env, &Some(serv)))
let def_list = crate::bindings::analysis::chase_actor(env, &serv).ok()?;
let env = TypeEnv(
env.0
.iter()
.filter(|&(k, _)| def_list.contains(&k.as_str()))
.map(|(k, v)| (k.clone(), v.clone()))
.collect(),
);
Some(candid::pretty::candid::compile(&env, &Some(serv)))
}

/// Merge canister metadata candid:args and candid:service into a service constructor.
Expand Down

0 comments on commit 625483a

Please sign in to comment.