Please suggest what i am doing incorrect here
kill_anonymous call needs to come from the anonymous itself:
let who = ensure_signed(origin)?; let when = (height, ext_index); let proxy = Self::anonymous_account(&spawner, &proxy_type, index, Some(when)); ensure!(proxy == who, Error::<T>::NoPermission);
Of course the only way to access an anonymous proxy origin is via
proxy.proxy. Your call above is correct, but you need to wrap it in a
proxy.proxy such that the origin is the anon proxy.
proxy.proxy( real: <YOUR_ANON_PROXY>, force_proxy_type: Any, call: proxy.killAnonymous( /* args */ ) )
This is because the spawner may have set a new account as the proxy and removed itself, so the permission to kill an anon rests with the anon itself.