Skip to content

Commit

Permalink
Cleanup (#3)
Browse files Browse the repository at this point in the history
* Rename neurons rust to neurons

* Rename voting to contracts

* Rename contract to nqg

* Add missing image

* Rename contract to governance, remove unused dependency
  • Loading branch information
cptartur authored May 9, 2024
1 parent 649cac5 commit ff49347
Show file tree
Hide file tree
Showing 25 changed files with 28 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Voting Contract Checks
name: Contracts Checks
on:
pull_request:
push:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Neurons Rust Checks
name: Neurons Checks
on:
pull_request:
push:
Expand Down
25 changes: 9 additions & 16 deletions contracts/Cargo.lock

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

2 changes: 1 addition & 1 deletion contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["offchain"]
members = ["governance"]

[workspace.dependencies]
soroban-sdk = "20.4.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "offchain"
name = "governance"
version = "0.1.0"
edition = "2021"

Expand All @@ -8,7 +8,6 @@ crate-type = ["cdylib", "lib"]

[dependencies]
soroban-sdk = { workspace = true, features = ["alloc"] }
soroban_decimal_numbers = "0.1.2"
soroban-fixed-point-math.workspace = true

[dev_dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This contract is a part of implementation of
the [Neural Quorum Governance](https://stellarcommunityfund.gitbook.io/module-library) mechanism.

![architecture](../voting_system/image.png)
![architecture](image.png)

Currently, because
of [resource constraints](https://developers.stellar.org/docs/reference/resource-limits-fees#resource-limits) and to
Expand Down
Binary file added contracts/governance/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub mod types;
pub const DECIMALS: i128 = 1_000_000_000_000_000_000;

#[contract]
pub struct VotingSystemOffchain;
pub struct VotingSystem;

type ContractResult<T> = Result<T, VotingSystemError>;

Expand Down Expand Up @@ -66,7 +66,7 @@ pub enum DataKey {
}

#[contractimpl]
impl VotingSystemOffchain {
impl VotingSystem {
/// Initialize the governance contract.
pub fn initialize(env: Env, admin: Address, current_round: u32) {
assert!(!is_set_admin(&env), "Admin already set");
Expand Down Expand Up @@ -186,7 +186,7 @@ impl VotingSystemOffchain {
}

#[contractimpl]
impl Admin for VotingSystemOffchain {
impl Admin for VotingSystem {
fn transfer_admin(env: Env, new_admin: Address) {
require_admin(&env);
set_admin(&env, &new_admin);
Expand All @@ -200,7 +200,7 @@ impl Admin for VotingSystemOffchain {
}

#[contractimpl]
impl Governance for VotingSystemOffchain {
impl Governance for VotingSystem {
fn add_layer(
env: Env,
raw_neurons: Vec<(String, I256)>,
Expand Down Expand Up @@ -332,7 +332,7 @@ impl Governance for VotingSystemOffchain {
let neural_governance = read_neural_governance(&env).unwrap();
let mut result: Map<String, I256> = Map::new(&env);
for layer_id in neural_governance.layers {
let layer_result = VotingSystemOffchain::get_layer_result(env.clone(), layer_id)?;
let layer_result = VotingSystem::get_layer_result(env.clone(), layer_id)?;
for (key, value) in layer_result {
result.set(
key.clone(),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use offchain::{VotingSystemOffchain, VotingSystemOffchainClient};
use governance::{VotingSystem, VotingSystemClient};
use soroban_sdk::testutils::Address as AddressTrait;
use soroban_sdk::{Address, Env};

pub fn deploy_contract_without_initialization(env: &Env) -> VotingSystemOffchainClient {
let contract_id = env.register_contract(None, VotingSystemOffchain);
let contract_client = VotingSystemOffchainClient::new(env, &contract_id);
pub fn deploy_contract_without_initialization(env: &Env) -> VotingSystemClient {
let contract_id = env.register_contract(None, VotingSystem);
let contract_client = VotingSystemClient::new(env, &contract_id);

contract_client
}

pub fn deploy_contract(env: &Env) -> VotingSystemOffchainClient {
pub fn deploy_contract(env: &Env) -> VotingSystemClient {
let contract_client = deploy_contract_without_initialization(env);

env.mock_all_auths();
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use soroban_sdk::{vec, Env, String, Vec, I256};

use offchain::types::VotingSystemError;
use offchain::LayerAggregator;
use governance::types::VotingSystemError;
use governance::LayerAggregator;

use crate::e2e::common::contract_utils::deploy_contract;

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use soroban_sdk::{vec, Env, Map, String, Vec, I256};

use offchain::types::{Vote, VotingSystemError};
use offchain::{LayerAggregator, DECIMALS};
use governance::types::{Vote, VotingSystemError};
use governance::{LayerAggregator, DECIMALS};

use crate::e2e::common::contract_utils::deploy_contract;

Expand Down
File renamed without changes.

0 comments on commit ff49347

Please sign in to comment.