Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { workspace = true }
frame-support = { workspace = true }
precompile-utils = { workspace = true }
scale-info = { workspace = true }
serde = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
subtensor-macros = { workspace = true }
sp-core = { workspace = true }

[lints]
workspace = true
Expand All @@ -29,9 +26,7 @@ fast-blocks = []
std = [
"codec/std",
"frame-support/std",
"precompile-utils/std",
"scale-info/std",
"serde/std",
"sp-core/std",
"sp-runtime/std",
]
75 changes: 1 addition & 74 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#![cfg_attr(not(feature = "std"), no_std)]
use core::fmt::{self, Display, Formatter};

use codec::{Compact, CompactAs, Decode, Encode, Error as CodecError, MaxEncodedLen};
use frame_support::pallet_prelude::*;
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
use sp_runtime::{
MultiSignature,
traits::{IdentifyAccount, Verify},
};
use subtensor_macros::freeze_struct;

/// Balance of an account.
pub type Balance = u64;
Expand All @@ -35,75 +31,6 @@ pub type Nonce = u32;
/// Transfers below SMALL_TRANSFER_LIMIT are considered small transfers
pub const SMALL_TRANSFER_LIMIT: Balance = 500_000_000; // 0.5 TAO

#[freeze_struct("f1746d0b1911967")]
#[repr(transparent)]
#[derive(
Deserialize,
Serialize,
Clone,
Copy,
Decode,
Default,
Encode,
Eq,
Hash,
MaxEncodedLen,
Ord,
PartialEq,
PartialOrd,
RuntimeDebug,
TypeInfo,
)]
pub struct NetUid(u16);

impl NetUid {
pub const ROOT: NetUid = Self(0);

pub fn is_root(&self) -> bool {
*self == Self::ROOT
}

pub fn next(&self) -> NetUid {
Self(self.0.saturating_add(1))
}
}

impl Display for NetUid {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
Display::fmt(&self.0, f)
}
}

impl CompactAs for NetUid {
type As = u16;

fn encode_as(&self) -> &Self::As {
&self.0
}

fn decode_from(v: Self::As) -> Result<Self, CodecError> {
Ok(Self(v))
}
}

impl From<Compact<NetUid>> for NetUid {
fn from(c: Compact<NetUid>) -> Self {
c.0
}
}

impl From<NetUid> for u16 {
fn from(val: NetUid) -> Self {
val.0
}
}

impl From<u16> for NetUid {
fn from(value: u16) -> Self {
Self(value)
}
}

#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, MaxEncodedLen, TypeInfo,
)]
Expand Down
2 changes: 0 additions & 2 deletions pallets/admin-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ substrate-fixed = { workspace = true }
pallet-evm-chain-id = { workspace = true }
pallet-drand = { workspace = true, default-features = false }
sp-consensus-grandpa = { workspace = true }
subtensor-runtime-common = { workspace = true }

[dev-dependencies]
sp-core = { workspace = true }
Expand Down Expand Up @@ -68,7 +67,6 @@ std = [
"sp-tracing/std",
"sp-weights/std",
"substrate-fixed/std",
"subtensor-runtime-common/std"
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down
Loading
Loading