Skip to content

Commit

Permalink
Allow hosts to set rankings during enrollment
Browse files Browse the repository at this point in the history
  • Loading branch information
ismellike committed Dec 26, 2024
1 parent 3871efa commit ec5bbc9
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,34 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"set_rankings"
],
"properties": {
"set_rankings": {
"type": "object",
"required": [
"id",
"rankings"
],
"properties": {
"id": {
"$ref": "#/definitions/Uint128"
},
"rankings": {
"type": "array",
"items": {
"$ref": "#/definitions/MemberMsg_for_String"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Update the contract's ownership. The `action` to be provided can be either to propose transferring ownership to an account, accept a pending ownership transfer, or renounce the ownership permanently.",
"type": "object",
Expand Down Expand Up @@ -579,6 +607,22 @@
},
"additionalProperties": false
},
"MemberMsg_for_String": {
"type": "object",
"required": [
"addr",
"seed"
],
"properties": {
"addr": {
"type": "string"
},
"seed": {
"$ref": "#/definitions/Uint64"
}
},
"additionalProperties": false
},
"ModuleInstantiateInfo": {
"description": "Information needed to instantiate a module.",
"type": "object",
Expand Down
3 changes: 3 additions & 0 deletions contracts/arena-competition-enrollment/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ pub fn execute(
group_contract_info,
require_team_size,
),
ExecuteMsg::SetRankings { id, rankings } => {
execute::set_rankings(deps, env, info, id, rankings)
}
ExecuteMsg::TriggerExpiration { id, escrow_id } => {
execute::trigger_expiration(deps, env, info, id, escrow_id)
}
Expand Down
31 changes: 30 additions & 1 deletion contracts/arena-competition-enrollment/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use arena_interface::{
competition::msg::EscrowInstantiateInfo,
core::{CompetitionModuleQuery, CompetitionModuleResponse},
group::{self, GroupContractInfo},
group::{self, GroupContractInfo, MemberMsg},
};
use arena_league_module::msg::LeagueInstantiateExt;
use arena_tournament_module::{msg::TournamentInstantiateExt, state::EliminationType};
Expand Down Expand Up @@ -611,3 +611,32 @@ fn get_min_min_members(competition_type: &CompetitionType) -> Uint64 {
},
}
}

pub fn set_rankings(
deps: DepsMut,
_env: Env,
info: MessageInfo,
id: Uint128,
rankings: Vec<MemberMsg<String>>,
) -> Result<Response, ContractError> {
let enrollment = enrollment_entries().load(deps.storage, id.u128())?;

ensure!(
enrollment.host == info.sender,
ContractError::Unauthorized {}
);

let msg = WasmMsg::Execute {
contract_addr: enrollment.group_contract.to_string(),
msg: to_json_binary(&group::ExecuteMsg::UpdateMembers {
to_add: None,
to_update: Some(rankings),
to_remove: None,
})?,
funds: vec![],
};

Ok(Response::new()
.add_attribute("action", "set_rankings")
.add_message(msg))
}
6 changes: 5 additions & 1 deletion contracts/arena-competition-enrollment/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use arena_interface::fees::FeeInformation;
use arena_interface::{fees::FeeInformation, group::MemberMsg};
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Coin, Uint128, Uint64};
use cw_utils::Expiration;
Expand Down Expand Up @@ -48,6 +48,10 @@ pub enum ExecuteMsg {
id: Uint128,
members: Vec<String>,
},
SetRankings {
id: Uint128,
rankings: Vec<MemberMsg<String>>,
},
}

#[cw_serde]
Expand Down
2 changes: 1 addition & 1 deletion scripts/state.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"neutron": {
"neutron-1": {
"code_ids": {
"arena_competition_enrollment": 2876,
"arena_competition_enrollment": 2878,
"arena_core": 2217,
"arena_discord_identity": 2874,
"arena_escrow": 2875,
Expand Down

0 comments on commit ec5bbc9

Please sign in to comment.