-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from hadronlabs-org/feat/LIDO-73-contracts-skel…
…eton feat: LIDO-73. Contracts skeleton
- Loading branch information
Showing
26 changed files
with
558 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[alias] | ||
schema = "run --bin lido-distribution-schema" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[package] | ||
authors = [] | ||
description = "Contract to support staking distribution" | ||
edition = "2021" | ||
name = "lido-distribution" | ||
version = "1.0.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. | ||
"contract.wasm", | ||
"hash.txt", | ||
] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[features] | ||
# for more explicit tests, cargo test --features=backtraces | ||
backtraces = ["cosmwasm-std/backtraces"] | ||
# use library feature to disable all instantiate/execute/query exports | ||
library = [] | ||
|
||
[dependencies] | ||
cosmos-sdk-proto = { workspace = true } | ||
prost = { workspace = true } | ||
prost-types = { workspace = true } | ||
protobuf = { workspace = true } | ||
tendermint-proto = { workspace = true } | ||
|
||
cosmwasm-schema = { workspace = true } | ||
cosmwasm-std = { workspace = true } | ||
cw-storage-plus = { workspace = true } | ||
cw-ownable = { workspace = true } | ||
cw2 = { workspace = true } | ||
cw20 = { workspace = true } | ||
schemars = { workspace = true } | ||
serde = { workspace = true } | ||
serde-json-wasm = { workspace = true } | ||
|
||
neutron-sdk = { workspace = true } | ||
|
||
[dev-dependencies] | ||
cosmwasm-storage = { workspace = true } | ||
cw-multi-test = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# LIDO Staking distribution |
14 changes: 14 additions & 0 deletions
14
contracts/distribution/src/bin/lido-distribution-schema.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use cosmwasm_schema::write_api; | ||
use lido_distribution::{ | ||
msg::{ExecuteMsg, InstantiateMsg, MigrateMsg}, | ||
state::QueryMsg, | ||
}; | ||
|
||
fn main() { | ||
write_api! { | ||
instantiate: InstantiateMsg, | ||
query: QueryMsg, | ||
execute: ExecuteMsg, | ||
migrate: MigrateMsg | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use cosmwasm_std::{entry_point, to_json_binary, Deps}; | ||
use cosmwasm_std::{Binary, DepsMut, Env, MessageInfo, Response, StdResult}; | ||
use cw2::set_contract_version; | ||
use neutron_sdk::bindings::msg::NeutronMsg; | ||
use neutron_sdk::bindings::query::NeutronQuery; | ||
use neutron_sdk::NeutronResult; | ||
|
||
use crate::state::{QueryMsg, CONFIG}; | ||
use crate::{ | ||
msg::{ExecuteMsg, InstantiateMsg, MigrateMsg}, | ||
state::Config, | ||
}; | ||
|
||
const CONTRACT_NAME: &str = concat!("crates.io:lido-validators_stats__", env!("CARGO_PKG_NAME")); | ||
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn instantiate( | ||
deps: DepsMut, | ||
_env: Env, | ||
_info: MessageInfo, | ||
msg: InstantiateMsg, | ||
) -> NeutronResult<Response> { | ||
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; | ||
|
||
let owner = deps.api.addr_validate(&msg.owner)?; | ||
|
||
cw_ownable::initialize_owner(deps.storage, deps.api, Some(&msg.owner))?; | ||
|
||
let config = &Config { owner }; | ||
|
||
CONFIG.save(deps.storage, config)?; | ||
|
||
Ok(Response::default()) | ||
} | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn query(deps: Deps<NeutronQuery>, env: Env, msg: QueryMsg) -> StdResult<Binary> { | ||
match msg { | ||
QueryMsg::Config {} => query_config(deps, env), | ||
} | ||
} | ||
|
||
fn query_config(deps: Deps<NeutronQuery>, _env: Env) -> StdResult<Binary> { | ||
let config = CONFIG.load(deps.storage)?; | ||
to_json_binary(&config) | ||
} | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn execute( | ||
_deps: DepsMut<NeutronQuery>, | ||
_env: Env, | ||
_info: MessageInfo, | ||
msg: ExecuteMsg, | ||
) -> NeutronResult<Response<NeutronMsg>> { | ||
match msg {} | ||
} | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult<Response> { | ||
deps.api.debug("WASMDEBUG: migrate"); | ||
Ok(Response::default()) | ||
} | ||
|
||
// TODO: add tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod contract; | ||
pub mod msg; | ||
pub mod state; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use cosmwasm_schema::cw_serde; | ||
|
||
#[cw_serde] | ||
pub struct InstantiateMsg { | ||
pub owner: String, | ||
} | ||
|
||
#[cw_serde] | ||
pub enum ExecuteMsg {} | ||
|
||
#[cw_serde] | ||
pub struct MigrateMsg {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use cosmwasm_schema::{cw_serde, QueryResponses}; | ||
|
||
use cosmwasm_std::Addr; | ||
use cw_storage_plus::Item; | ||
|
||
#[cw_serde] | ||
pub struct Config { | ||
pub owner: Addr, | ||
} | ||
|
||
#[cw_serde] | ||
#[derive(QueryResponses)] | ||
pub enum QueryMsg { | ||
#[returns(Config)] | ||
Config {}, | ||
} | ||
|
||
pub const CONFIG: Item<Config> = Item::new("config"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[alias] | ||
schema = "run --bin lido-strategy-schema" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[package] | ||
authors = [] | ||
description = "Contract to implement staking strategies" | ||
edition = "2021" | ||
name = "lido-strategy" | ||
version = "1.0.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. | ||
"contract.wasm", | ||
"hash.txt", | ||
] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[features] | ||
# for more explicit tests, cargo test --features=backtraces | ||
backtraces = ["cosmwasm-std/backtraces"] | ||
# use library feature to disable all instantiate/execute/query exports | ||
library = [] | ||
|
||
[dependencies] | ||
cosmos-sdk-proto = { workspace = true } | ||
prost = { workspace = true } | ||
prost-types = { workspace = true } | ||
protobuf = { workspace = true } | ||
tendermint-proto = { workspace = true } | ||
|
||
cosmwasm-schema = { workspace = true } | ||
cosmwasm-std = { workspace = true } | ||
cw-storage-plus = { workspace = true } | ||
cw-ownable = { workspace = true } | ||
cw2 = { workspace = true } | ||
cw20 = { workspace = true } | ||
schemars = { workspace = true } | ||
serde = { workspace = true } | ||
serde-json-wasm = { workspace = true } | ||
|
||
neutron-sdk = { workspace = true } | ||
|
||
[dev-dependencies] | ||
cosmwasm-storage = { workspace = true } | ||
cw-multi-test = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# LIDO Strategy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use cosmwasm_schema::write_api; | ||
use lido_strategy::{ | ||
msg::{ExecuteMsg, InstantiateMsg, MigrateMsg}, | ||
state::QueryMsg, | ||
}; | ||
|
||
fn main() { | ||
write_api! { | ||
instantiate: InstantiateMsg, | ||
query: QueryMsg, | ||
execute: ExecuteMsg, | ||
migrate: MigrateMsg | ||
} | ||
} |
Oops, something went wrong.