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
8 changes: 8 additions & 0 deletions packages/rs-dpp/src/tokens/contract_info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ pub mod v0;
PartialEq,
)]
#[platform_serialize(unversioned)] //versioned directly, no need to use platform_version
#[cfg_attr(
any(
feature = "fixtures-and-mocks",
feature = "state-transition-serde-conversion"
),
derive(serde::Serialize, serde::Deserialize),
serde(untagged)
)]
pub enum TokenContractInfo {
V0(TokenContractInfoV0),
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Expand Down
8 changes: 8 additions & 0 deletions packages/rs-dpp/src/tokens/contract_info/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ use derive_more::From;
use platform_value::Identifier;

#[derive(Debug, Clone, Encode, Decode, From, PartialEq)]
#[cfg_attr(
any(
feature = "fixtures-and-mocks",
feature = "state-transition-serde-conversion"
),
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "camelCase")
)]
/// Token contract info
pub struct TokenContractInfoV0 {
/// The contract id of the token
Expand Down
39 changes: 37 additions & 2 deletions packages/wasm-dpp2/src/tokens/contract_info.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
use crate::identifier::IdentifierWasm;
use crate::impl_wasm_type_info;
use crate::{impl_wasm_conversions, impl_wasm_type_info};
use dpp::data_contract::TokenContractPosition;
use dpp::tokens::contract_info::TokenContractInfo;
use dpp::tokens::contract_info::v0::TokenContractInfoV0Accessors;
use wasm_bindgen::prelude::wasm_bindgen;

#[wasm_bindgen(typescript_custom_section)]
const TOKEN_CONTRACT_INFO_TYPES_TS: &str = r#"
/**
* TokenContractInfo serialized as a plain object.
*/
export interface TokenContractInfoObject {
contractId: Uint8Array;
tokenContractPosition: number;
}

/**
* TokenContractInfo serialized as JSON (with string identifiers).
*/
export interface TokenContractInfoJSON {
contractId: string;
tokenContractPosition: number;
}
"#;

#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(typescript_type = "TokenContractInfoObject")]
pub type TokenContractInfoObjectJs;

#[wasm_bindgen(typescript_type = "TokenContractInfoJSON")]
pub type TokenContractInfoJSONJs;
}

#[wasm_bindgen(js_name = "TokenContractInfo")]
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(transparent)]
pub struct TokenContractInfoWasm(TokenContractInfo);

impl From<TokenContractInfo> for TokenContractInfoWasm {
Expand Down Expand Up @@ -38,4 +67,10 @@ impl TokenContractInfoWasm {
}
}

impl_wasm_conversions!(
TokenContractInfoWasm,
TokenContractInfo,
TokenContractInfoObjectJs,
TokenContractInfoJSONJs
);
impl_wasm_type_info!(TokenContractInfoWasm, TokenContractInfo);
Loading