use crate::msg::to_any;
use crate::proto::qorechain::pqc::v1 as pb;
use cosmrs::Any;
pub const REGISTER_PQC_KEY: &str = "/qorechain.pqc.v1.MsgRegisterPQCKey";
pub const REGISTER_PQC_KEY_V2: &str = "/qorechain.pqc.v1.MsgRegisterPQCKeyV2";
pub const MIGRATE_PQC_KEY: &str = "/qorechain.pqc.v1.MsgMigratePQCKey";
pub const DEPRECATE_ALGORITHM: &str = "/qorechain.pqc.v1.MsgDeprecateAlgorithm";
pub const DISABLE_ALGORITHM: &str = "/qorechain.pqc.v1.MsgDisableAlgorithm";
pub fn register_pqc_key(
sender: impl Into<String>,
dilithium_pubkey: Vec<u8>,
ecdsa_pubkey: Vec<u8>,
key_type: impl Into<String>,
) -> pb::MsgRegisterPqcKey {
pb::MsgRegisterPqcKey {
sender: sender.into(),
dilithium_pubkey,
ecdsa_pubkey,
key_type: key_type.into(),
}
}
pub fn register_pqc_key_any(
sender: impl Into<String>,
dilithium_pubkey: Vec<u8>,
ecdsa_pubkey: Vec<u8>,
key_type: impl Into<String>,
) -> Any {
to_any(
®ister_pqc_key(sender, dilithium_pubkey, ecdsa_pubkey, key_type),
REGISTER_PQC_KEY,
)
}
pub fn register_pqc_key_v2(
sender: impl Into<String>,
public_key: Vec<u8>,
algorithm_id: u32,
ecdsa_pubkey: Vec<u8>,
key_type: impl Into<String>,
) -> pb::MsgRegisterPqcKeyV2 {
pb::MsgRegisterPqcKeyV2 {
sender: sender.into(),
public_key,
algorithm_id,
ecdsa_pubkey,
key_type: key_type.into(),
}
}
pub fn register_pqc_key_v2_any(
sender: impl Into<String>,
public_key: Vec<u8>,
algorithm_id: u32,
ecdsa_pubkey: Vec<u8>,
key_type: impl Into<String>,
) -> Any {
to_any(
®ister_pqc_key_v2(sender, public_key, algorithm_id, ecdsa_pubkey, key_type),
REGISTER_PQC_KEY_V2,
)
}
pub fn migrate_pqc_key(
sender: impl Into<String>,
old_public_key: Vec<u8>,
new_public_key: Vec<u8>,
new_algorithm_id: u32,
old_signature: Vec<u8>,
new_signature: Vec<u8>,
) -> pb::MsgMigratePqcKey {
pb::MsgMigratePqcKey {
sender: sender.into(),
old_public_key,
new_public_key,
new_algorithm_id,
old_signature,
new_signature,
}
}
pub fn migrate_pqc_key_any(
sender: impl Into<String>,
old_public_key: Vec<u8>,
new_public_key: Vec<u8>,
new_algorithm_id: u32,
old_signature: Vec<u8>,
new_signature: Vec<u8>,
) -> Any {
to_any(
&migrate_pqc_key(
sender,
old_public_key,
new_public_key,
new_algorithm_id,
old_signature,
new_signature,
),
MIGRATE_PQC_KEY,
)
}
pub fn deprecate_algorithm(
authority: impl Into<String>,
algorithm_id: u32,
migration_blocks: i64,
replacement_algorithm_id: u32,
) -> pb::MsgDeprecateAlgorithm {
pb::MsgDeprecateAlgorithm {
authority: authority.into(),
algorithm_id,
migration_blocks,
replacement_algorithm_id,
}
}
pub fn deprecate_algorithm_any(
authority: impl Into<String>,
algorithm_id: u32,
migration_blocks: i64,
replacement_algorithm_id: u32,
) -> Any {
to_any(
&deprecate_algorithm(
authority,
algorithm_id,
migration_blocks,
replacement_algorithm_id,
),
DEPRECATE_ALGORITHM,
)
}
pub fn disable_algorithm(
authority: impl Into<String>,
algorithm_id: u32,
reason: impl Into<String>,
) -> pb::MsgDisableAlgorithm {
pb::MsgDisableAlgorithm {
authority: authority.into(),
algorithm_id,
reason: reason.into(),
}
}
pub fn disable_algorithm_any(
authority: impl Into<String>,
algorithm_id: u32,
reason: impl Into<String>,
) -> Any {
to_any(
&disable_algorithm(authority, algorithm_id, reason),
DISABLE_ALGORITHM,
)
}