Skip to content

Commit 8442095

Browse files
committed
commit Cargo.lock
1 parent 3bcf9d2 commit 8442095

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

common/src/lib.rs

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -184,34 +184,33 @@ impl TryFrom<u8> for ProxyType {
184184
14 => Ok(Self::SudoUncheckedSetCode),
185185
15 => Ok(Self::SwapHotkey),
186186
16 => Ok(Self::SubnetLeaseBeneficiary),
187+
17 => Ok(Self::RootClaim),
187188
_ => Err(()),
188189
}
189190
}
190191
}
191192

192-
impl TryInto<u8> for ProxyType {
193-
type Error = ();
194-
195-
fn try_into(self) -> Result<u8, Self::Error> {
196-
match self {
197-
Self::Any => Ok(0),
198-
Self::Owner => Ok(1),
199-
Self::NonCritical => Ok(2),
200-
Self::NonTransfer => Ok(3),
201-
Self::Senate => Ok(4),
202-
Self::NonFungible => Ok(5),
203-
Self::Triumvirate => Ok(6),
204-
Self::Governance => Ok(7),
205-
Self::Staking => Ok(8),
206-
Self::Registration => Ok(9),
207-
Self::Transfer => Ok(10),
208-
Self::SmallTransfer => Ok(11),
209-
Self::RootWeights => Ok(12),
210-
Self::ChildKeys => Ok(13),
211-
Self::SudoUncheckedSetCode => Ok(14),
212-
Self::SwapHotkey => Ok(15),
213-
Self::SubnetLeaseBeneficiary => Ok(16),
214-
Self::RootClaim => Err(()),
193+
impl From<ProxyType> for u8 {
194+
fn from(proxy_type: ProxyType) -> Self {
195+
match proxy_type {
196+
ProxyType::Any => 0,
197+
ProxyType::Owner => 1,
198+
ProxyType::NonCritical => 2,
199+
ProxyType::NonTransfer => 3,
200+
ProxyType::Senate => 4,
201+
ProxyType::NonFungible => 5,
202+
ProxyType::Triumvirate => 6,
203+
ProxyType::Governance => 7,
204+
ProxyType::Staking => 8,
205+
ProxyType::Registration => 9,
206+
ProxyType::Transfer => 10,
207+
ProxyType::SmallTransfer => 11,
208+
ProxyType::RootWeights => 12,
209+
ProxyType::ChildKeys => 13,
210+
ProxyType::SudoUncheckedSetCode => 14,
211+
ProxyType::SwapHotkey => 15,
212+
ProxyType::SubnetLeaseBeneficiary => 16,
213+
ProxyType::RootClaim => 17,
215214
}
216215
}
217216
}

pallets/proxy/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ pub mod pallet {
145145
+ PartialOrd
146146
+ frame::traits::InstanceFilter<<Self as Config>::RuntimeCall>
147147
+ Default
148-
+ MaxEncodedLen;
148+
+ MaxEncodedLen
149+
+ TryFrom<u8>;
149150

150151
/// The base amount of currency needed to reserve for creating a proxy.
151152
///

precompiles/src/proxy.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use sp_runtime::{
1515
traits::{Dispatchable, StaticLookup},
1616
};
1717
use sp_std::boxed::Box;
18+
use sp_std::convert::{TryFrom, TryInto};
1819
use sp_std::vec;
1920
use sp_std::vec::Vec;
2021
use subtensor_runtime_common::ProxyType;
@@ -253,9 +254,11 @@ where
253254
let mut result: Vec<(H256, U256, U256)> = vec![];
254255
for proxy in proxies.0 {
255256
let delegate: [u8; 32] = proxy.delegate.into();
256-
let proxy_type: u8 =
257-
proxy
258-
.proxy_type
257+
258+
let proxy_type: ProxyType = proxy.proxy_type;
259+
260+
let proxy_type_u8: u8 =
261+
proxy_type
259262
.try_into()
260263
.map_err(|_| PrecompileFailure::Error {
261264
exit_status: ExitError::Other("Invalid proxy type".into()),
@@ -266,7 +269,7 @@ where
266269
.map_err(|_| PrecompileFailure::Error {
267270
exit_status: ExitError::Other("Invalid delay".into()),
268271
})?;
269-
result.push((delegate.into(), proxy_type.into(), delay.into()));
272+
result.push((delegate.into(), proxy_type_u8.into(), delay.into()));
270273
}
271274

272275
Ok(result)

0 commit comments

Comments
 (0)