Skip to content
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

DAO refactoring: bring submit proposal to neutron msg #69

Merged
merged 8 commits into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
4d2a9f1b9d6e8181c3ecca744ae5e42667cfe9e4c2dccca1ae08a14235e18508 ibc_transfer.wasm
cbf63b17bd81dcce44a3ba3d5b4e61ec6f1da8e3a1f90041d518ac4397b326bd neutron_interchain_queries.wasm
a34dcff26a3709f5382d526ade65d41384e376eda7a28c07c588f4301554debe neutron_interchain_txs.wasm
8d13b8165b699d9709414c20e41a2adedb0591a00f9be633fb4684b31a016fda neutron_validators_test.wasm
adca79965655a68948496a29f6a83631a722a9605215bcce3a4fa7df6500d10e ibc_transfer.wasm
df49934ef96ebd0e14c0a124dae19c3fdb5b009de25c928d27af139948a59330 neutron_interchain_queries.wasm
6994f64f65b0bd639e6621dcb5c02eb79741cfb0ea18d6a25e83b16b7c9b9785 neutron_interchain_txs.wasm
684c447068313f47d3754625ba73134bc16f83939633f309c6891dc3d41c73c7 neutron_validators_test.wasm
2e7a0f168de97eebf4080df6f9fe23987fc96ac5852f29ca6c489dee7b10e6dd reflect.wasm
Binary file modified artifacts/ibc_transfer.wasm
Binary file not shown.
Binary file modified artifacts/neutron_interchain_queries.wasm
Binary file not shown.
Binary file modified artifacts/neutron_interchain_txs.wasm
Binary file not shown.
Binary file modified artifacts/neutron_validators_test.wasm
Binary file not shown.
87 changes: 87 additions & 0 deletions packages/neutron-sdk/schema/neutron_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,27 @@
}
},
"additionalProperties": false
},
{
"description": "SubmitProposal sends a proposal to neutron's Admin module",
"type": "object",
"required": [
"submit_proposal"
],
"properties": {
"submit_proposal": {
"type": "object",
"required": [
"proposals"
],
"properties": {
"proposals": {
"$ref": "#/definitions/Proposals"
}
}
}
},
"additionalProperties": false
}
],
"definitions": {
Expand Down Expand Up @@ -329,6 +350,72 @@
}
}
},
"ParamChange": {
"description": "ParamChange defines the struct for parameter change request",
"type": "object",
"required": [
"key",
"subspace",
"value"
],
"properties": {
"key": {
"description": "*key** is a name of parameter. Unique for subspace",
"type": "string"
},
"subspace": {
"description": "*subspace** is a key of module to which the parameter to change belongs. Unique for each module",
"type": "string"
},
"value": {
"description": "*value** is a new value for given parameter. Non unique",
"type": "string"
}
}
},
"ParamChangeProposal": {
"description": "ParamChangeProposal defines the struct for single parameter change proposal",
"type": "object",
"required": [
"description",
"param_changes",
"title"
],
"properties": {
"description": {
"description": "*descriptionr** is a text description of proposal. Non unique",
"type": "string"
},
"param_changes": {
"description": "*param_changes** is a vector of params to be changed. Non unique",
"type": "array",
"items": {
"$ref": "#/definitions/ParamChange"
}
},
"title": {
"description": "*title** is a text title of proposal. Non unique",
"type": "string"
}
}
},
"Proposals": {
"description": "Proposals defines the struct for various proposals which neutron may accept (currently only parameter change)",
"type": "object",
"properties": {
"param_change_proposal": {
"description": "*param_change_proposal** is a parameter change proposal field",
"anyOf": [
{
"$ref": "#/definitions/ParamChangeProposal"
},
{
"type": "null"
}
]
}
}
},
"ProtobufAny": {
"description": "Type for wrapping any protobuf message",
"type": "object",
Expand Down
44 changes: 44 additions & 0 deletions packages/neutron-sdk/src/bindings/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ pub enum NeutronMsg {
timeout_timestamp: u64,
fee: IbcFee,
},
/// SubmitProposal sends a proposal to neutron's Admin module
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Rename to SubmitAdminProposal
  2. Write a comment that explicitly states that this type of messages can only be executed by the Neutron DAO

SubmitProposal { proposals: Proposals },
}

impl NeutronMsg {
Expand Down Expand Up @@ -227,6 +229,16 @@ impl NeutronMsg {
pub fn remove_interchain_query(query_id: u64) -> Self {
NeutronMsg::RemoveInterchainQuery { query_id }
}

/// Basic helper to define a parameter change proposal passed to AdminModule:
/// * **proposal** is struct which contains proposal that should change network parameter
pub fn submit_param_change_proposal(proposal: ParamChangeProposal) -> Self {
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
NeutronMsg::SubmitProposal {
proposals: Proposals {
Copy link
Contributor

@ratik ratik Dec 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mb it's Proposal and not Proposals?

param_change_proposal: Option::from(proposal),
},
}
}
}

impl From<NeutronMsg> for CosmosMsg<NeutronMsg> {
Expand Down Expand Up @@ -264,3 +276,35 @@ pub struct MsgIbcTransferResponse {
/// **channel** is a src channel on neutron side trasaction was submitted from
pub channel: String,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
/// Proposals defines the struct for various proposals which neutron may accept (currently only parameter change)
pub struct Proposals {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Rename to AdminProposal
  2. Add a comment that currently only param change proposals are implemented, but new types of admin proposals might be implemented in the future

/// **param_change_proposal** is a parameter change proposal field
pub param_change_proposal: Option<ParamChangeProposal>,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
/// ParamChangeProposal defines the struct for single parameter change proposal
pub struct ParamChangeProposal {
/// **title** is a text title of proposal. Non unique
pub title: String,
/// **descriptionr** is a text description of proposal. Non unique
pub description: String,
/// **param_changes** is a vector of params to be changed. Non unique
pub param_changes: Vec<ParamChange>,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
/// ParamChange defines the struct for parameter change request
pub struct ParamChange {
/// **subspace** is a key of module to which the parameter to change belongs. Unique for each module
pub subspace: String,
/// **key** is a name of parameter. Unique for subspace
pub key: String,
/// **value** is a new value for given parameter. Non unique
pub value: String,
}