What is the best way to disable ink! smart contracts code upgradability for a class of contracts? Below I describe what I need it for, just in case. Thank you!
For my use case, I need my pallet to accept a user-defined algorithm for getting a value used in an extrinsic call handler. As I see, the best way for that case is ink! smart contract. The user provides the contract address and a getter selector to my pallet and then my extrinsic handler can get the value invoking some user-defined code. It may look like this:
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::my_extrinsic())]
pub fn my_extrinsic(origin: OriginFor<T>) -> DispatchResult {
ensure_signed(origin)?;
let user_defined = pallet_contracts::Pallet::<T>::bare_call(<contract address and a value getter selector provided by user earlier>).result?;
if Self::check(user_defined) {
Self::do_foo();
} else {
Self::do_bar();
}
Ok(())
}
}
The problem here is that by default the user may replace the value getter using the set_code_hash, but I want the getter to be non-upgradable and the algorithm never changes.
I can create a fork of the pallet-contracts
to remove set_code_hash
from it but is there a better approach?