Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ pub trait MixnetQueryClient {

// state/sys-params-related

async fn admin(&self) -> Result<cw_controllers::AdminResponse, NyxdError> {
self.query_mixnet_contract(MixnetQueryMsg::Admin {}).await
}

async fn get_mixnet_contract_version(&self) -> Result<ContractBuildInformation, NyxdError> {
self.query_mixnet_contract(MixnetQueryMsg::GetContractVersion {})
.await
Expand Down Expand Up @@ -580,6 +584,7 @@ mod tests {
msg: MixnetQueryMsg,
) -> u32 {
match msg {
MixnetQueryMsg::Admin {} => client.admin().ignore(),
MixnetQueryMsg::GetAllFamiliesPaged { limit, start_after } => client
.get_all_family_members_paged(start_after, limit)
.ignore(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ pub trait MixnetSigningClient {

// state/sys-params-related

async fn update_admin(
&self,
admin: String,
fee: Option<Fee>,
) -> Result<ExecuteResult, NyxdError> {
self.execute_mixnet_contract(fee, MixnetExecuteMsg::UpdateAdmin { admin }, vec![])
.await
}

async fn update_rewarding_validator_address(
&self,
address: AccountId,
Expand Down Expand Up @@ -760,6 +769,7 @@ mod tests {
msg: MixnetExecuteMsg,
) {
match msg {
MixnetExecuteMsg::UpdateAdmin { admin } => client.update_admin(admin, None).ignore(),
MixnetExecuteMsg::AssignNodeLayer { mix_id, layer } => {
client.assign_node_layer(mix_id, layer, None).ignore()
}
Expand Down
1 change: 1 addition & 0 deletions common/cosmwasm-smart-contracts/mixnet-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repository = { workspace = true }
bs58 = "0.4.0"
cosmwasm-std = { workspace = true }
cosmwasm-schema = { workspace = true }
cw-controllers = { workspace = true }
cw2 = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] }
serde_repr = { workspace = true }
Expand Down
4 changes: 4 additions & 0 deletions common/cosmwasm-smart-contracts/mixnet-contract/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ use crate::{EpochEventId, EpochState, IdentityKey, MixId, OperatingCostRange, Pr
use contracts_common::signing::verifier::ApiVerifierError;
use contracts_common::Percent;
use cosmwasm_std::{Addr, Coin, Decimal, Uint128};
use cw_controllers::AdminError;
use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
pub enum MixnetContractError {
#[error("could not perform contract migration: {comment}")]
FailedMigration { comment: String },

#[error(transparent)]
Admin(#[from] AdminError),

#[error("{source}")]
StdErr {
#[from]
Expand Down
9 changes: 9 additions & 0 deletions common/cosmwasm-smart-contracts/mixnet-contract/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ impl InitialRewardingParams {

#[cw_serde]
pub enum ExecuteMsg {
/// Change the admin
UpdateAdmin {
admin: String,
},

AssignNodeLayer {
mix_id: MixId,
layer: Layer,
Expand Down Expand Up @@ -292,6 +297,7 @@ pub enum ExecuteMsg {
impl ExecuteMsg {
pub fn default_memo(&self) -> String {
match self {
ExecuteMsg::UpdateAdmin { admin } => format!("updating contract admin to {admin}"),
ExecuteMsg::AssignNodeLayer { mix_id, layer } => {
format!("assigning mix {mix_id} for layer {layer:?}")
}
Expand Down Expand Up @@ -408,6 +414,9 @@ impl ExecuteMsg {
#[cw_serde]
#[cfg_attr(feature = "schema", derive(QueryResponses))]
pub enum QueryMsg {
#[cfg_attr(feature = "schema", returns(cw_controllers::AdminResponse))]
Admin {},

// families
/// Gets the list of families registered in this contract.
#[cfg_attr(feature = "schema", returns(PagedFamiliesResponse))]
Expand Down
6 changes: 5 additions & 1 deletion common/cosmwasm-smart-contracts/mixnet-contract/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ impl Index<Layer> for LayerDistribution {
#[cw_serde]
pub struct ContractState {
/// Address of the contract owner.
pub owner: Addr,
#[deprecated(
note = "use explicit ADMIN instead. this field will be removed in future release"
)]
#[serde(default)]
pub owner: Option<Addr>,

/// Address of "rewarding validator" (nym-api) that's allowed to send any rewarding-related transactions.
pub rewarding_validator_address: Addr,
Expand Down
2 changes: 2 additions & 0 deletions contracts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/mixnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ cosmwasm-schema = { workspace = true, optional = true }
cosmwasm-std = { workspace = true }
cosmwasm-storage = { workspace = true }
cosmwasm-derive = { workspace = true }
cw-controllers = { workspace = true }
cw2 = { workspace = true }
cw-storage-plus = { workspace = true }

Expand Down
58 changes: 56 additions & 2 deletions contracts/mixnet/schema/nym-mixnet-contract.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,28 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ExecuteMsg",
"oneOf": [
{
"description": "Change the admin",
"type": "object",
"required": [
"update_admin"
],
"properties": {
"update_admin": {
"type": "object",
"required": [
"admin"
],
"properties": {
"admin": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -1692,6 +1714,19 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "QueryMsg",
"oneOf": [
{
"type": "object",
"required": [
"admin"
],
"properties": {
"admin": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Gets the list of families registered in this contract.",
"type": "object",
Expand Down Expand Up @@ -2937,6 +2972,21 @@
},
"sudo": null,
"responses": {
"admin": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AdminResponse",
"description": "Returned from Admin.query_admin()",
"type": "object",
"properties": {
"admin": {
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
},
"get_all_delegations": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "PagedAllDelegationsResponse",
Expand Down Expand Up @@ -8140,7 +8190,6 @@
"description": "The current state of the mixnet contract.",
"type": "object",
"required": [
"owner",
"params",
"rewarding_denom",
"rewarding_validator_address",
Expand All @@ -8149,9 +8198,14 @@
"properties": {
"owner": {
"description": "Address of the contract owner.",
"allOf": [
"default": null,
"deprecated": true,
"anyOf": [
{
"$ref": "#/definitions/Addr"
},
{
"type": "null"
}
]
},
Expand Down
22 changes: 22 additions & 0 deletions contracts/mixnet/schema/raw/execute.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ExecuteMsg",
"oneOf": [
{
"description": "Change the admin",
"type": "object",
"required": [
"update_admin"
],
"properties": {
"update_admin": {
"type": "object",
"required": [
"admin"
],
"properties": {
"admin": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down
13 changes: 13 additions & 0 deletions contracts/mixnet/schema/raw/query.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "QueryMsg",
"oneOf": [
{
"type": "object",
"required": [
"admin"
],
"properties": {
"admin": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Gets the list of families registered in this contract.",
"type": "object",
Expand Down
15 changes: 15 additions & 0 deletions contracts/mixnet/schema/raw/response_to_admin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AdminResponse",
"description": "Returned from Admin.query_admin()",
"type": "object",
"properties": {
"admin": {
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
}
8 changes: 6 additions & 2 deletions contracts/mixnet/schema/raw/response_to_get_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "The current state of the mixnet contract.",
"type": "object",
"required": [
"owner",
"params",
"rewarding_denom",
"rewarding_validator_address",
Expand All @@ -13,9 +12,14 @@
"properties": {
"owner": {
"description": "Address of the contract owner.",
"allOf": [
"default": null,
"deprecated": true,
"anyOf": [
{
"$ref": "#/definitions/Addr"
},
{
"type": "null"
}
]
},
Expand Down
1 change: 1 addition & 0 deletions contracts/mixnet/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub const PENDING_INTERVAL_EVENTS_NAMESPACE: &str = "pie";
pub const LAST_EPOCH_EVENT_ID_KEY: &str = "lee";
pub const LAST_INTERVAL_EVENT_ID_KEY: &str = "lie";

pub const ADMIN_STORAGE_KEY: &str = "admin";
pub const CONTRACT_STATE_KEY: &str = "state";

pub const LAYER_DISTRIBUTION_KEY: &str = "layers";
Expand Down
Loading