use alloc::string::{String, ToString};
use keetanetwork_client::{Vote as CoreVote, VoteQuote as CoreVoteQuote};
use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen]
#[derive(Clone)]
pub struct Vote {
inner: CoreVote,
}
#[wasm_bindgen]
impl Vote {
#[wasm_bindgen(getter)]
pub fn hash(&self) -> String {
self.inner.hash().to_string()
}
#[wasm_bindgen(js_name = toHex)]
pub fn to_hex(&self) -> String {
hex::encode(self.inner.as_bytes())
}
}
impl From<CoreVote> for Vote {
fn from(inner: CoreVote) -> Self {
Self { inner }
}
}
#[wasm_bindgen]
#[derive(Clone)]
pub struct VoteQuote {
inner: CoreVoteQuote,
}
#[wasm_bindgen]
impl VoteQuote {
#[wasm_bindgen(getter)]
pub fn hash(&self) -> String {
self.inner.hash().to_string()
}
#[wasm_bindgen(js_name = toHex)]
pub fn to_hex(&self) -> String {
hex::encode(self.inner.as_vote().as_bytes())
}
}
impl VoteQuote {
pub(crate) fn inner(&self) -> CoreVoteQuote {
self.inner.clone()
}
}
impl From<CoreVoteQuote> for VoteQuote {
fn from(inner: CoreVoteQuote) -> Self {
Self { inner }
}
}