generated from substrate-developer-hub/substrate-node-template
-
Notifications
You must be signed in to change notification settings - Fork 60
/
traits.rs
96 lines (82 loc) · 1.96 KB
/
traits.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
use frame_support::dispatch::PostDispatchInfo;
use frame_support::pallet_prelude::DispatchResultWithPostInfo;
use frame_support::sp_runtime::DispatchResult;
use frame_support::weights::Weight;
use sp_core::{H160, H256, U256};
use sp_std::vec::Vec;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PaymentInfo<Balance, AssetId, Price> {
Native(Balance),
NonNative(Balance, AssetId, Price),
}
/// Handler for dealing with fees
pub trait DepositFee<AccountId, AssetId, Balance> {
fn deposit_fee(who: &AccountId, currency: AssetId, amount: Balance) -> DispatchResult;
}
pub trait EVMPermit {
#![allow(clippy::too_many_arguments)]
fn validate_permit(
source: H160,
target: H160,
data: Vec<u8>,
value: U256,
gas_limit: u64,
deadline: U256,
v: u8,
r: H256,
s: H256,
) -> DispatchResult;
fn dispatch_permit(
source: H160,
target: H160,
data: Vec<u8>,
value: U256,
gas_limit: u64,
max_fee_per_gas: U256,
max_priority_fee_per_gas: Option<U256>,
nonce: Option<U256>,
access_list: Vec<(H160, Vec<H256>)>,
) -> DispatchResultWithPostInfo;
fn gas_price() -> (U256, Weight);
fn dispatch_weight(gas_limit: u64) -> Weight;
fn permit_nonce(account: H160) -> U256;
fn on_dispatch_permit_error();
}
impl EVMPermit for () {
fn validate_permit(
_source: H160,
_target: H160,
_data: Vec<u8>,
_value: U256,
_gas_limit: u64,
_deadline: U256,
_v: u8,
_r: H256,
_s: H256,
) -> DispatchResult {
Ok(())
}
fn dispatch_permit(
_source: H160,
_target: H160,
_data: Vec<u8>,
_value: U256,
_gas_limit: u64,
_max_fee_per_gas: U256,
_max_priority_fee_per_gas: Option<U256>,
_nonce: Option<U256>,
_access_list: Vec<(H160, Vec<H256>)>,
) -> DispatchResultWithPostInfo {
Ok(PostDispatchInfo::default())
}
fn gas_price() -> (U256, Weight) {
Default::default()
}
fn dispatch_weight(_gas_limit: u64) -> Weight {
Weight::zero()
}
fn permit_nonce(_account: H160) -> U256 {
U256::default()
}
fn on_dispatch_permit_error() {}
}