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
1,693 changes: 1,693 additions & 0 deletions smart-contracts/repos-v0/Cargo.lock

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions smart-contracts/repos-v0/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "repo_registry"
version = "0.1.0"
authors = ["Gittensor Team"]
edition = "2021"

[dependencies]
ink = { version = "5", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }

[lib]
path = "lib.rs"

[features]
default = ["std"]
std = [
"ink/std",
"scale/std",
"scale-info/std",
]
ink-as-dependency = []
79 changes: 79 additions & 0 deletions smart-contracts/repos-v0/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
use scale::{Decode, Encode};

/// Errors that can occur in the RepoRegistry contract
#[derive(Debug, PartialEq, Eq, Encode, Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum Error {
/// Caller is not the contract owner
NotOwner,
/// Caller is not the repository owner
NotRepoOwner,
/// Caller is not a whitelisted validator hotkey
NotWhitelistedVoter,
/// Contract is paused
Paused,
/// Repository not found
RepoNotFound,
/// Repository exists but is not active
RepoNotActive,
/// Repository is already registered and active
AlreadyRegistered,
/// GitHub id must be non-zero
InvalidGithubId,
/// Full name must be lowercase "owner/repo"
InvalidFullName,
/// Zero address not allowed
ZeroAddress,
/// Registry full and every repo is inside its immunity window
NoPrunableSlot,
/// Per-block registration cap reached
TooManyRegistrationsThisBlock,
/// No bounds registered for this param key
UnknownParamKey,
/// Value outside the allowed bounds
ValueOutOfBounds,
/// Change rate limit not yet elapsed
RateLimited,
/// Label is empty, too long, or contains control characters
InvalidLabel,
/// Label multiplier cap reached
TooManyLabels,
/// Label multiplier not found
LabelNotFound,
/// Branch pattern fails validation
InvalidPattern,
/// Branch pattern cap reached
TooManyPatterns,
/// Duplicate branch pattern
DuplicatePattern,
/// Basket must not be empty
EmptyBasket,
/// Basket exceeds the basket cap
BasketTooLarge,
/// Duplicate repo id in basket
DuplicateBasketEntry,
/// Basket weights must be non-zero
ZeroWeight,
/// Basket weights must sum to 65535
WeightSumMismatch,
/// Voter already whitelisted
VoterAlreadyAdded,
/// Voter not in whitelist
VoterNotFound,
/// Voter whitelist cap reached
TooManyVoters,
/// Bounds must satisfy min <= max
InvalidBounds,
/// Param bounds key cap reached
TooManyParamKeys,
/// Constants failed validation
InvalidConfig,
/// Fee stake transfer failed
FeeTransferFailed,
/// Fee stake delta shortfall (silent cap detected)
FeeShortfall,
/// Fee recycle failed
RecycleFailed,
/// set_code_hash failed
SetCodeFailed,
}
137 changes: 137 additions & 0 deletions smart-contracts/repos-v0/events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
use ink::prelude::string::String;
use ink::prelude::vec::Vec;
use ink::primitives::{AccountId, Hash};

/// A repository was registered (fee paid and recycled).
/// Consumed by the das-github-mirror reconciler: track + deep-backfill.
#[ink::event]
pub struct RepositoryRegistered {
#[ink(topic)]
pub github_id: u64,
pub full_name: String,
pub owner: AccountId,
pub fee_paid: u64,
pub reg_block: u64,
}

/// A repository was removed by its owner (forced = team escape hatch).
/// Consumed by the das-github-mirror reconciler: untrack.
#[ink::event]
pub struct RepositoryDeregistered {
#[ink(topic)]
pub github_id: u64,
pub full_name: String,
pub forced: bool,
}

/// A repository was pruned to free a slot for `replaced_by`.
/// Consumed by the das-github-mirror reconciler: untrack.
#[ink::event]
pub struct RepositoryPruned {
#[ink(topic)]
pub github_id: u64,
pub full_name: String,
pub replaced_by: u64,
}

/// Repository renamed on GitHub; id is stable, metadata updated.
#[ink::event]
pub struct FullNameUpdated {
#[ink(topic)]
pub github_id: u64,
pub old_full_name: String,
pub new_full_name: String,
}

#[ink::event]
pub struct RepoOwnershipTransferred {
#[ink(topic)]
pub github_id: u64,
pub old_owner: AccountId,
pub new_owner: AccountId,
}

#[ink::event]
pub struct ParamSet {
#[ink(topic)]
pub github_id: u64,
pub key: u8,
pub value: u64,
}

#[ink::event]
pub struct LabelMultiplierSet {
#[ink(topic)]
pub github_id: u64,
pub label: String,
pub value: u64,
}

#[ink::event]
pub struct LabelMultiplierRemoved {
#[ink(topic)]
pub github_id: u64,
pub label: String,
}

#[ink::event]
pub struct BranchPatternsSet {
#[ink(topic)]
pub github_id: u64,
pub patterns: Vec<String>,
}

#[ink::event]
pub struct BasketSet {
#[ink(topic)]
pub hotkey: AccountId,
pub entries: Vec<(u64, u16)>,
}

#[ink::event]
pub struct BasketCleared {
#[ink(topic)]
pub hotkey: AccountId,
}

#[ink::event]
pub struct VoterAdded {
#[ink(topic)]
pub hotkey: AccountId,
}

#[ink::event]
pub struct VoterRemoved {
#[ink(topic)]
pub hotkey: AccountId,
}

#[ink::event]
pub struct BoundsSet {
#[ink(topic)]
pub key: u8,
pub min: u64,
pub max: u64,
}

#[ink::event]
pub struct ConfigUpdated {}

#[ink::event]
pub struct PausedSet {
pub paused: bool,
}

#[ink::event]
pub struct OwnerChanged {
#[ink(topic)]
pub old_owner: AccountId,
#[ink(topic)]
pub new_owner: AccountId,
}

#[ink::event]
pub struct CodeHashSet {
#[ink(topic)]
pub code_hash: Hash,
}
Loading