Setting initial DKG Epoch on init
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::types::{EncodedBTEPublicKeyWithProof, EncodedEd25519PublicKey};
|
||||
use crate::types::{BlockHeight, EncodedBTEPublicKeyWithProof, EncodedEd25519PublicKey};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct InstantiateMsg {}
|
||||
pub struct InstantiateMsg {
|
||||
pub dealing_exchange_beginning_height: BlockHeight,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod queries;
|
||||
pub mod storage;
|
||||
pub mod transactions;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use coconut_dkg_common::types::Epoch;
|
||||
use cw_storage_plus::Item;
|
||||
|
||||
pub(crate) const CURRENT_EPOCH: Item<Epoch> = Item::new("current_epoch");
|
||||
@@ -0,0 +1,2 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
use crate::error::ContractError;
|
||||
use coconut_dkg_common::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
|
||||
use coconut_dkg_common::types::{Epoch, EpochState};
|
||||
use cosmwasm_std::{entry_point, Deps, DepsMut, Env, MessageInfo, QueryResponse, Response};
|
||||
use epoch::storage as epoch_storage;
|
||||
|
||||
mod constants;
|
||||
mod dealers;
|
||||
@@ -18,11 +20,21 @@ mod support;
|
||||
/// `msg` is the contract initialization message, sort of like a constructor call.
|
||||
#[entry_point]
|
||||
pub fn instantiate(
|
||||
_deps: DepsMut<'_>,
|
||||
_env: Env,
|
||||
deps: DepsMut<'_>,
|
||||
env: Env,
|
||||
_info: MessageInfo,
|
||||
_msg: InstantiateMsg,
|
||||
msg: InstantiateMsg,
|
||||
) -> Result<Response, ContractError> {
|
||||
epoch_storage::CURRENT_EPOCH.save(
|
||||
deps.storage,
|
||||
&Epoch {
|
||||
id: 0,
|
||||
state: EpochState::PublicKeySubmission {
|
||||
begun_at: env.block.height,
|
||||
finish_by: msg.dealing_exchange_beginning_height,
|
||||
},
|
||||
},
|
||||
)?;
|
||||
Ok(Response::default())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user