-
Notifications
You must be signed in to change notification settings - Fork 8
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
BCI-1511: only contract schema changes #359
Merged
augustbleeds
merged 5 commits into
develop
from
augustus.BCI-1511.only-contract-schema-changes
Aug 29, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
use std::env::current_dir; | ||
use std::fs::create_dir_all; | ||
|
||
use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; | ||
use cosmwasm_schema::write_api; | ||
|
||
use access_controller::msg::{ExecuteMsg, InstantiateMsg, 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); | ||
write_api! { | ||
instantiate: InstantiateMsg, | ||
execute: ExecuteMsg, | ||
query: QueryMsg, | ||
} | ||
} |
135 changes: 135 additions & 0 deletions
135
contracts/access-controller/schema/access-controller.json
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,135 @@ | ||
{ | ||
"contract_name": "access-controller", | ||
"contract_version": "1.0.0", | ||
"idl_version": "1.0.0", | ||
"instantiate": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "InstantiateMsg", | ||
"type": "object" | ||
}, | ||
"execute": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "ExecuteMsg", | ||
"oneOf": [ | ||
{ | ||
"type": "string", | ||
"enum": [ | ||
"accept_ownership" | ||
] | ||
}, | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"add_access" | ||
], | ||
"properties": { | ||
"add_access": { | ||
"type": "object", | ||
"required": [ | ||
"address" | ||
], | ||
"properties": { | ||
"address": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"remove_access" | ||
], | ||
"properties": { | ||
"remove_access": { | ||
"type": "object", | ||
"required": [ | ||
"address" | ||
], | ||
"properties": { | ||
"address": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"transfer_ownership" | ||
], | ||
"properties": { | ||
"transfer_ownership": { | ||
"type": "object", | ||
"required": [ | ||
"to" | ||
], | ||
"properties": { | ||
"to": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
] | ||
}, | ||
"query": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "QueryMsg", | ||
"oneOf": [ | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"has_access" | ||
], | ||
"properties": { | ||
"has_access": { | ||
"type": "object", | ||
"required": [ | ||
"address" | ||
], | ||
"properties": { | ||
"address": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"owner" | ||
], | ||
"properties": { | ||
"owner": { | ||
"type": "object" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
] | ||
}, | ||
"migrate": null, | ||
"sudo": null, | ||
"responses": { | ||
"has_access": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Boolean", | ||
"type": "boolean" | ||
}, | ||
"owner": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Addr", | ||
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", | ||
"type": "string" | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
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
5 changes: 5 additions & 0 deletions
5
contracts/access-controller/schema/raw/response_to_has_access.json
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,5 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Boolean", | ||
"type": "boolean" | ||
} |
6 changes: 6 additions & 0 deletions
6
contracts/access-controller/schema/raw/response_to_owner.json
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,6 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Addr", | ||
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", | ||
"type": "string" | ||
} |
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 |
---|---|---|
@@ -1,19 +1,39 @@ | ||
use std::env::current_dir; | ||
use std::fs::create_dir_all; | ||
use std::fs::{create_dir_all, remove_dir_all, rename}; | ||
|
||
use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; | ||
use cosmwasm_schema::{export_schema, remove_schemas, schema_for, write_api}; | ||
|
||
use deviation_flagging_validator::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; | ||
use deviation_flagging_validator::state::State; | ||
|
||
fn main() { | ||
// clean directory | ||
let mut out_dir = current_dir().unwrap(); | ||
out_dir.push("schema"); | ||
remove_dir_all(&out_dir).unwrap(); | ||
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!(State), &out_dir); | ||
write_api! { | ||
instantiate: InstantiateMsg, | ||
execute: ExecuteMsg, | ||
query: QueryMsg, | ||
} | ||
|
||
// put main schema under main folder for codegen.js (else it will error) | ||
let mut main_dir = out_dir.clone(); | ||
main_dir.push("main"); | ||
create_dir_all(&main_dir).unwrap(); | ||
|
||
let mut main_file = out_dir.clone(); | ||
main_file.push("deviation-flagging-validator.json"); | ||
|
||
let mut new_location = main_dir.clone(); | ||
new_location.push("deviation-flagging-validator.json"); | ||
rename(&main_file, &new_location).unwrap(); | ||
|
||
// put other hand-exported schemas in seperate folder | ||
let mut other_dir = out_dir.clone(); | ||
other_dir.push("other"); | ||
create_dir_all(&other_dir).unwrap(); | ||
export_schema(&schema_for!(State), &other_dir); | ||
} |
Oops, something went wrong.
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.
Hmm why the need for this? The crate's readme specifically states it's a dev dependency
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.
https://book.cosmwasm.com/basics/good-practices.html#json-schema -- just copied over here. It also didn't work as a dev dependency as I wasn't able to use it in schema.rs