Skip to content

Commit

Permalink
feat: cwd-proposal-multiple new schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ratik committed Aug 15, 2023
1 parent bad87ff commit 5f6dafb
Show file tree
Hide file tree
Showing 26 changed files with 9,894 additions and 337 deletions.
72 changes: 8 additions & 64 deletions contracts/dao/proposal/cwd-proposal-multiple/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -1,67 +1,11 @@
use std::env::current_dir;
use std::fs::create_dir_all;

use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for};
use cosmwasm_std::Addr;
use cwd_hooks::HooksResponse;
use cwd_interface::voting::InfoResponse;
use cwd_proposal_multiple::{
msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg},
query::{ProposalListResponse, ProposalResponse, VoteListResponse, VoteResponse},
state::Config,
};
use cwd_voting::pre_propose::ProposalCreationPolicy;
use cosmwasm_schema::write_api;
use cwd_proposal_multiple::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
let mut out_dir = current_dir().unwrap();
out_dir.push("schema");
create_dir_all(&out_dir).unwrap();
remove_schemas(&out_dir).unwrap();

export_schema(&schema_for!(InstantiateMsg), &out_dir);
export_schema(&schema_for!(ExecuteMsg), &out_dir);
export_schema(&schema_for!(QueryMsg), &out_dir);
export_schema(&schema_for!(MigrateMsg), &out_dir);

export_schema(&schema_for!(InfoResponse), &out_dir);
export_schema(&schema_for!(ProposalResponse), &out_dir);
export_schema(&schema_for!(VoteResponse), &out_dir);

// Auto TS code generation expects the query return type as QueryNameResponse
// Here we map query responses to the correct name
export_schema_with_title(&schema_for!(Config), &out_dir, "ConfigResponse");
export_schema_with_title(
&schema_for!(Vec<Addr>),
&out_dir,
"GovernanceModulesResponse",
);
export_schema_with_title(
&schema_for!(ProposalListResponse),
&out_dir,
"ListProposalsResponse",
);
export_schema_with_title(
&schema_for!(VoteListResponse),
&out_dir,
"ListVotesResponse",
);
export_schema_with_title(&schema_for!(u64), &out_dir, "ProposalCountResponse");
export_schema_with_title(
&schema_for!(ProposalListResponse),
&out_dir,
"ReverseProposalsResponse",
);
export_schema_with_title(&schema_for!(Addr), &out_dir, "DaoResponse");
export_schema_with_title(
&schema_for!(HooksResponse),
&out_dir,
"ProposalHooksResponse",
);
export_schema_with_title(&schema_for!(HooksResponse), &out_dir, "VoteHooksResponse");
export_schema_with_title(&schema_for!(VoteResponse), &out_dir, "GetVoteResponse");
export_schema_with_title(
&schema_for!(ProposalCreationPolicy),
&out_dir,
"ProposalCreationPolicyResponse",
);
write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
execute: ExecuteMsg,
migrate: MigrateMsg,
}
}
Loading

0 comments on commit 5f6dafb

Please sign in to comment.