-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
♻️ Split seda-chain-contracts
into DataRequests
and Staking
#61
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5edc034
refactor: split contracts, convert some unit tests to integration
jamesondh 3dfff2c
chore: update/fix deploy workflows
jamesondh 7e64b56
chore: update lint to generate schema only for proxy
jamesondh c7a23d4
chore: remove uncommented test
jamesondh 548b060
chore: update contracts in deploy CI
jamesondh 3415d9c
fix: proxy argument in deploy CI
jamesondh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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::write_api; | ||
|
||
use common::msg::{DataRequestsExecuteMsg, DataRequestsQueryMsg}; | ||
use data_requests::msg::InstantiateMsg; | ||
|
||
fn main() { | ||
write_api! { | ||
instantiate: InstantiateMsg, | ||
execute: DataRequestsExecuteMsg, | ||
query: DataRequestsQueryMsg, | ||
} | ||
} |
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,104 @@ | ||
use common::msg::DataRequestsExecuteMsg as ExecuteMsg; | ||
use common::msg::DataRequestsQueryMsg as QueryMsg; | ||
#[cfg(not(feature = "library"))] | ||
use cosmwasm_std::{entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response}; | ||
use cw2::set_contract_version; | ||
|
||
use crate::data_request::data_requests; | ||
use crate::error::ContractError; | ||
use crate::msg::InstantiateMsg; | ||
use crate::state::{DATA_REQUESTS_COUNT, PROXY_CONTRACT, TOKEN}; | ||
|
||
use crate::data_request_result::data_request_results; | ||
use cosmwasm_std::StdResult; | ||
|
||
// version info for migration info | ||
const CONTRACT_NAME: &str = "data-requests"; | ||
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, | ||
) -> Result<Response, ContractError> { | ||
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; | ||
DATA_REQUESTS_COUNT.save(deps.storage, &0)?; | ||
TOKEN.save(deps.storage, &msg.token)?; | ||
PROXY_CONTRACT.save(deps.storage, &deps.api.addr_validate(&msg.proxy)?)?; | ||
Ok(Response::new().add_attribute("method", "instantiate")) | ||
} | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn execute( | ||
deps: DepsMut, | ||
env: Env, | ||
info: MessageInfo, | ||
msg: ExecuteMsg, | ||
) -> Result<Response, ContractError> { | ||
match msg { | ||
ExecuteMsg::PostDataRequest { posted_dr } => { | ||
data_requests::post_data_request(deps, info, posted_dr) | ||
} | ||
ExecuteMsg::CommitDataResult { | ||
dr_id, | ||
commitment, | ||
sender, | ||
} => data_request_results::commit_result(deps, info, dr_id, commitment, sender), | ||
ExecuteMsg::RevealDataResult { | ||
dr_id, | ||
reveal, | ||
sender, | ||
} => data_request_results::reveal_result(deps, info, env, dr_id, reveal, sender), | ||
} | ||
} | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> { | ||
match msg { | ||
QueryMsg::GetDataRequest { dr_id } => { | ||
to_binary(&data_requests::get_data_request(deps, dr_id)?) | ||
} | ||
QueryMsg::GetDataRequestsFromPool { position, limit } => to_binary( | ||
&data_requests::get_data_requests_from_pool(deps, position, limit)?, | ||
), | ||
QueryMsg::GetCommittedDataResult { dr_id, executor } => to_binary( | ||
&data_request_results::get_committed_data_result(deps, dr_id, executor)?, | ||
), | ||
QueryMsg::GetCommittedDataResults { dr_id } => to_binary( | ||
&data_request_results::get_committed_data_results(deps, dr_id)?, | ||
), | ||
QueryMsg::GetRevealedDataResult { dr_id, executor } => to_binary( | ||
&data_request_results::get_revealed_data_result(deps, dr_id, executor)?, | ||
), | ||
QueryMsg::GetRevealedDataResults { dr_id } => to_binary( | ||
&data_request_results::get_revealed_data_results(deps, dr_id)?, | ||
), | ||
QueryMsg::GetResolvedDataResult { dr_id } => to_binary( | ||
&data_request_results::get_resolved_data_result(deps, dr_id)?, | ||
), | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod init_tests { | ||
use super::*; | ||
use cosmwasm_std::coins; | ||
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; | ||
|
||
#[test] | ||
fn proper_initialization() { | ||
let mut deps = mock_dependencies(); | ||
|
||
let msg = InstantiateMsg { | ||
token: "token".to_string(), | ||
proxy: "proxy".to_string(), | ||
}; | ||
let info = mock_info("creator", &coins(1000, "token")); | ||
|
||
// we can just call .unwrap() to assert this was a success | ||
let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); | ||
assert_eq!(0, res.messages.len()); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha nice!