git.delta.rocks / unique-network / refs/commits / 40ef8e0c0f72

difftreelog

doc(pallet-evm-transaction-payment): document public api

Yaroslav Bolyukin2022-07-12parent: #68058b4.patch.diff
in: master

2 files changed

addedpallets/evm-transaction-payment/README.mddiffbeforeafterboth
--- /dev/null
+++ b/pallets/evm-transaction-payment/README.md
@@ -0,0 +1,5 @@
+# Evm transaction payment pallet
+
+pallet-evm-transaction-payment is a bridge between pallet-evm substrate calls and pallet-sponsoring.
+It doesn't provide any sponsoring logic by itself, instead all sponsoring handlers
+are loosly coupled via [`Config::EvmSponsorshipHandler`] trait.
\ No newline at end of file
modifiedpallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
1616
17#![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)]
1820
19use core::marker::PhantomData;21use core::marker::PhantomData;
20use fp_evm::WithdrawReason;22use fp_evm::WithdrawReason;
29pub mod pallet {31pub mod pallet {
30 use super::*;32 use super::*;
3133
32 use frame_support::traits::Currency;
33 use sp_std::vec::Vec;34 use sp_std::vec::Vec;
3435
35 #[pallet::config]36 #[pallet::config]
36 pub trait Config: frame_system::Config + pallet_evm::account::Config {37 pub trait Config: frame_system::Config + pallet_evm::account::Config {
38 /// Loosly-coupled handlers for evm call sponsoring
37 type EvmSponsorshipHandler: SponsorshipHandler<Self::CrossAccountId, (H160, Vec<u8>)>;39 type EvmSponsorshipHandler: SponsorshipHandler<Self::CrossAccountId, (H160, Vec<u8>)>;
38 type Currency: Currency<Self::AccountId>;
39 }40 }
4041
41 #[pallet::pallet]42 #[pallet::pallet]
42 #[pallet::generate_store(pub(super) trait Store)]43 #[pallet::generate_store(pub(super) trait Store)]
43 pub struct Pallet<T>(_);44 pub struct Pallet<T>(_);
44}45}
4546
47/// Implements [`fp_evm::TransactionValidityHack`], which provides sponsor address to pallet-evm
46pub struct TransactionValidityHack<T: Config>(PhantomData<*const T>);48pub struct TransactionValidityHack<T: Config>(PhantomData<*const T>);
47impl<T: Config> fp_evm::TransactionValidityHack<T::CrossAccountId> for TransactionValidityHack<T> {49impl<T: Config> fp_evm::TransactionValidityHack<T::CrossAccountId> for TransactionValidityHack<T> {
48 fn who_pays_fee(origin: H160, reason: &WithdrawReason) -> Option<T::CrossAccountId> {50 fn who_pays_fee(origin: H160, reason: &WithdrawReason) -> Option<T::CrossAccountId> {