Skip to content

Commit

Permalink
chore: migrate msgs to vrfdkgp for other contracts to use
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamle2 committed Sep 17, 2024
1 parent 1f7f16b commit f20a1de
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 34 deletions.
31 changes: 31 additions & 0 deletions package/base/vrfdkgp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
authors = ["Oraichain Labs"]
edition = "2021"
license = "AGPL-3.0"
name = "vrfdkgp"
version = "0.1.0"

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"artifacts/",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[features]
# use library feature to disable all instantiate/execute/query exports
library = []
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
cosmwasm-std = { version = "1.5" }
cosmwasm-schema = { version = "1.5" }
schemars = "0.8"
serde = { version = "1.0.204", default-features = false, features = ["derive"] }
thiserror = "1.0"
cw-utils = { workspace = true }
2 changes: 2 additions & 0 deletions package/base/vrfdkgp/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[dependencies]
std = { default-features = false }
File renamed without changes.
3 changes: 3 additions & 0 deletions package/base/vrfdkgp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod errors;
pub mod msg;
pub mod state;
File renamed without changes.
22 changes: 22 additions & 0 deletions package/base/vrfdkgp/src/state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::Coin;

use crate::msg::SharedStatus;

#[cw_serde]
pub struct Config {
/// The denom in which bounties are paid. This is typically the fee token of the chain.
pub total: u16,
pub threshold: u16,
pub dealer: u16,
// total dealers and rows have been shared
pub shared_dealer: u16,
pub shared_row: u16,
pub fee: Option<Coin>,
pub status: SharedStatus,
}

#[cw_serde]
pub struct Owner {
pub owner: String,
}
1 change: 1 addition & 0 deletions package/plus/vrfdkg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cosmwasm-std = { version = "1.5" }
cosmwasm-storage = { version = "1.5", features = ["iterator"] }
cosmwasm-schema = { version = "1.5" }
blsdkg = { path = "../../base/blsdkg" }
vrfdkgp = { path = "../../base/vrfdkgp" }
schemars = "0.8"
serde = { version = "1.0.204", default-features = false, features = ["derive"] }
thiserror = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion package/plus/vrfdkg/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::write_api;

use vrfdkg::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use vrfdkgp::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
write_api! {
Expand Down
7 changes: 4 additions & 3 deletions package/plus/vrfdkg/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ use blsdkg::{
};
use cw_storage_plus::Bound;
use cw_utils::one_coin;
use vrfdkgp::state::{Config, Owner};

use crate::errors::ContractError;
use crate::msg::{
use crate::state::{BEACONS, CONFIG, MEMBERS, OWNER, ROUND_COUNT};
use vrfdkgp::errors::ContractError;
use vrfdkgp::msg::{
DistributedShareData, ExecuteMsg, InstantiateMsg, Member, MemberMsg, MigrateMsg, QueryMsg,
ShareSig, ShareSigMsg, SharedDealerMsg, SharedRowMsg, SharedStatus,
};
use crate::state::{Config, Owner, BEACONS, CONFIG, MEMBERS, OWNER, ROUND_COUNT};

use cosmwasm_crypto::secp256k1_verify;

Expand Down
2 changes: 0 additions & 2 deletions package/plus/vrfdkg/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
pub mod contract;
pub mod errors;
pub mod msg;
pub mod state;

#[cfg(test)]
Expand Down
27 changes: 4 additions & 23 deletions package/plus/vrfdkg/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
use cosmwasm_schema::cw_serde;
use cw_storage_plus::{Item, Map};

use cosmwasm_std::Coin;
use vrfdkgp::{
msg::{DistributedShareData, Member},
state::{Config, Owner},
};

pub const CONFIG: Item<Config> = Item::new("config");
pub const ROUND_COUNT: Item<u64> = Item::new("round_count");
pub const OWNER: Item<Owner> = Item::new("owner");
pub const MEMBERS: Map<&[u8], Member> = Map::new("members");
pub const BEACONS: Map<&[u8], DistributedShareData> = Map::new("beacons");

use crate::msg::{DistributedShareData, Member, SharedStatus};

#[cw_serde]
pub struct Config {
/// The denom in which bounties are paid. This is typically the fee token of the chain.
pub total: u16,
pub threshold: u16,
pub dealer: u16,
// total dealers and rows have been shared
pub shared_dealer: u16,
pub shared_row: u16,
pub fee: Option<Coin>,
pub status: SharedStatus,
}

#[cw_serde]
pub struct Owner {
pub owner: String,
}
10 changes: 5 additions & 5 deletions package/plus/vrfdkg/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use crate::{
contract::{
execute, get_all_members, get_final_signed_message, instantiate, query, query_current,
},
msg::{
DistributedShareData, ExecuteMsg, InstantiateMsg, Member, MemberMsg, QueryMsg, ShareSigMsg,
SharedDealerMsg, SharedRowMsg, SharedStatus,
},
state::{Config, ROUND_COUNT},
state::ROUND_COUNT,
};
use vrfdkgp::{msg::{
DistributedShareData, ExecuteMsg, InstantiateMsg, Member, MemberMsg, QueryMsg, ShareSigMsg,
SharedDealerMsg, SharedRowMsg, SharedStatus,
}, state::Config};

use blsdkg::{
ff::Field,
Expand Down

0 comments on commit f20a1de

Please sign in to comment.