# 0.0.145 Breaking Changes for Kizuna ###### tags: `HDK 0.0.145` ## Returning Errors The custom guest error from string is now found in `WasmErrorInner`. Wrap the error in a `wasm_error!` macro (which also has the capability to display error line numbers). ```rust Err(e) => return Err(wasm_error!(WasmErrorInner::Guest(String::from(e)))) ``` Change the `error` util function from ```rust pub fn error<T>(reason: &str) -> ExternResult<T> { Err(WasmError::Guest(String::from(reason))) } ``` to ```rust pub fn error<T>(reason: &str) -> ExternResult<T> { Err(wasm_error!(WasmErrorInner::Guest(String::from(reason)))) } ``` ## Entry Definitions ### Entry Structures Add this helper to entry structures ```rust #[hdk_entry_helper] ``` Remove serde helper from entry structures ```rust #[serde(rename_all = "camelCase")] ``` Exclude `Serialize`, `Desiarialize`, `SerializedBytes`, and `Debug` from the derive in entry structures.`Clone` and `From` can still be derived. ```rust #[derive(Clone, From)] ``` Sample entry structure: ```rust #[derive(Clone, From)] #[hdk_entry_helper] pub struct P2PMessage { pub author: AgentPubKey, pub receiver: AgentPubKey, payload: Payload, time_sent: Timestamp, reply_to: Option<EntryHash>, } ``` Declaring EntryTypes ```rust // pre 0.0.145 // in lib.rs // entry_defs![ // P2PMessage::entry_def(), // P2PMessageReceipt::entry_def(), // P2PFileBytes::entry_def(), // P2PMessagePin::entry_def() // ]; // in contact.rs // entry_def!(P2PMessage // EntryDef { // id: "p2pmessage".into(), // visibility: EntryVisibility::Private, // crdt_type: CrdtType, // required_validations: RequiredValidations::default(), // required_validation_type: RequiredValidationType::Element // } // ); #[hdk_entry_defs] #[unit_enum(UnitEntryTypes)] pub enum EntryTypes { #[entry_def(required_validations = 5, visibility = "private")] P2PMessage(P2PMessage), ... } ``` ## Records and Actions Change all instances of `Element` to `Record` and `Header` to `Action`. Might be easier to just Replace All. Examples ```rust Element -> Record HeaderHash -> ActionHash ``` ## Decode `decode()` produces a `Result<<T>, SerializedBytesError>`. The `?` cannot be readily used as it produces a either a `<T>` or a `WasmError`. The `SerializedBytesError` cannot be directly converted to a WsmError. Remove the `?` operator in decodes and add a match clause to filter the Result. Sample code as used in signal decoding: ```rust let signal_detail_result: Result<SignalDetails, SerializedBytesError> = signal.decode()?; match signal_detail_result { Ok(signal_detail) => { emit_signal(&signal_detail)?; return Ok(()) }, Err(e) => return Err(wasm_error!(WasmErrorInner::Guest(String::from(e)))) } ``` ## Macros ### create_entry specify entry type taken from the `EntryTypes` enum declaration ```rust // pre-0.0.145 // create_entry(alias.clone())?; // return Ok(io); match create_entry(&EntryTypes::Alias(alias.clone())) { Ok(_) => return Ok(io), Err(_) => return error("problems were encountered during creation of entry"), } ```