difftreelog
doc(pallet-evm-migration): document public api
in: master
4 files changed
pallets/evm-migration/README.mddiffbeforeafterbothno changes
pallets/evm-migration/src/benchmarking.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![allow(missing_docs)]161817use super::{Call, Config, Pallet};19use super::{Call, Config, Pallet};18use frame_benchmarking::benchmarks;20use frame_benchmarking::benchmarks;pallets/evm-migration/src/lib.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617#![doc = include_str!("../README.md")]17#![cfg_attr(not(feature = "std"), no_std)]18#![cfg_attr(not(feature = "std"), no_std)]19#![deny(missing_docs)]182019pub use pallet::*;21pub use pallet::*;20#[cfg(feature = "runtime-benchmarks")]22#[cfg(feature = "runtime-benchmarks")]323433 #[pallet::config]35 #[pallet::config]34 pub trait Config: frame_system::Config + pallet_evm::Config {36 pub trait Config: frame_system::Config + pallet_evm::Config {37 /// Weights35 type WeightInfo: WeightInfo;38 type WeightInfo: WeightInfo;36 }39 }3740434644 #[pallet::error]47 #[pallet::error]45 pub enum Error<T> {48 pub enum Error<T> {49 /// Can only migrate to empty address.46 AccountNotEmpty,50 AccountNotEmpty,51 /// Migration of this account is not yet started, or already finished.47 AccountIsNotMigrating,52 AccountIsNotMigrating,48 }53 }4954535854 #[pallet::call]59 #[pallet::call]55 impl<T: Config> Pallet<T> {60 impl<T: Config> Pallet<T> {61 /// Start contract migration, inserts contract stub at target address,62 /// and marks account as pending, allowing to insert storage56 #[pallet::weight(<SelfWeightOf<T>>::begin())]63 #[pallet::weight(<SelfWeightOf<T>>::begin())]57 pub fn begin(origin: OriginFor<T>, address: H160) -> DispatchResult {64 pub fn begin(origin: OriginFor<T>, address: H160) -> DispatchResult {58 ensure_root(origin)?;65 ensure_root(origin)?;65 Ok(())72 Ok(())66 }73 }677475 /// Insert items into contract storage, this method can be called76 /// multiple times68 #[pallet::weight(<SelfWeightOf<T>>::set_data(data.len() as u32))]77 #[pallet::weight(<SelfWeightOf<T>>::set_data(data.len() as u32))]69 pub fn set_data(78 pub fn set_data(70 origin: OriginFor<T>,79 origin: OriginFor<T>,83 Ok(())92 Ok(())84 }93 }859495 /// Finish contract migration, allows it to be called.96 /// It is not possible to alter contract storage via [`Self::set_data`]97 /// after this call.86 #[pallet::weight(<SelfWeightOf<T>>::finish(code.len() as u32))]98 #[pallet::weight(<SelfWeightOf<T>>::finish(code.len() as u32))]87 pub fn finish(origin: OriginFor<T>, address: H160, code: Vec<u8>) -> DispatchResult {99 pub fn finish(origin: OriginFor<T>, address: H160, code: Vec<u8>) -> DispatchResult {88 ensure_root(origin)?;100 ensure_root(origin)?;97 }109 }98 }110 }99111112 /// Implements [`pallet_evm::OnMethodCall`], which reserves accounts with pending migration100 pub struct OnMethodCall<T>(PhantomData<T>);113 pub struct OnMethodCall<T>(PhantomData<T>);101 impl<T: Config> pallet_evm::OnMethodCall<T> for OnMethodCall<T> {114 impl<T: Config> pallet_evm::OnMethodCall<T> for OnMethodCall<T> {102 fn is_reserved(contract: &H160) -> bool {115 fn is_reserved(contract: &H160) -> bool {pallets/evm-migration/src/weights.rsdiffbeforeafterboth26#![cfg_attr(rustfmt, rustfmt_skip)]26#![cfg_attr(rustfmt, rustfmt_skip)]27#![allow(unused_parens)]27#![allow(unused_parens)]28#![allow(unused_imports)]28#![allow(unused_imports)]29#![allow(missing_docs)]29#![allow(clippy::unnecessary_cast)]30#![allow(clippy::unnecessary_cast)]303131use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};32use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};