diff --git a/crates/pop-drink/src/lib.rs b/crates/pop-drink/src/lib.rs index 601d0f3..863b962 100644 --- a/crates/pop-drink/src/lib.rs +++ b/crates/pop-drink/src/lib.rs @@ -103,12 +103,12 @@ pub mod testnet { /// ```rs /// #[drink::test(sandbox = Pop)] /// fn test_constructor_works(mut session: Session) { -/// let bundle = BundleProvider::local().unwrap(); +/// let bundle = BundleProvider::local().unwrap(); /// -/// // Deploy contract. -/// // -/// // `ContractError` is the error type used by the contract. -/// assert_ok!(deploy(&mut session, bundle, "new", input, salt, init_value)); +/// // Deploy contract. +/// // +/// // `ContractError` is the error type used by the contract. +/// assert_ok!(deploy(&mut session, bundle, "new", input, salt, init_value)); /// } /// ``` pub fn deploy( @@ -151,19 +151,19 @@ where /// ```rs /// #[drink::test(sandbox = Pop)] /// fn call_works(mut session: Session) { -/// let bundle = BundleProvider::local().unwrap(); -/// assert_ok!(deploy(&mut session, bundle, "new", input, salt, init_value)); +/// let bundle = BundleProvider::local().unwrap(); +/// assert_ok!(deploy(&mut session, bundle, "new", input, salt, init_value)); /// -/// // Call contract. -/// // -/// // `()` is the successful result type used by the contract. -/// // `ContractError` is the error type used by the contract. -/// call::( -/// session, -/// "transfer", -/// input, -/// init_value, -/// ) +/// // Call contract. +/// // +/// // `()` is the successful result type used by the contract. +/// // `ContractError` is the error type used by the contract. +/// call::( +/// session, +/// "transfer", +/// input, +/// init_value, +/// ) /// } /// ``` pub fn call( @@ -180,8 +180,9 @@ where { match session.call::(func_name, &input, endowment) { // If the call is reverted, decode the error into the specified error type. - Err(SessionError::CallReverted(error)) => - Err(E::decode(&mut &error[2..]).expect("Decoding failed")), + Err(SessionError::CallReverted(error)) => { + Err(E::decode(&mut &error[2..]).expect("Decoding failed")) + }, // If the call is successful, decode the last returned value. Ok(_) => Ok(session .record() @@ -206,12 +207,12 @@ where /// use drink::last_contract_event; /// /// assert_eq!( -/// last_contract_event::(&session).unwrap(), -/// ContractEvent { -/// value: 42, -/// } -/// .encode() -/// .as_slice() +/// last_contract_event::(&session).unwrap(), +/// ContractEvent { +/// value: 42, +/// } +/// .encode() +/// .as_slice() /// ); /// ``` pub fn last_contract_event(session: &Session) -> Option> diff --git a/crates/pop-drink/src/macros.rs b/crates/pop-drink/src/macros.rs index a1f7436..3bfeb44 100644 --- a/crates/pop-drink/src/macros.rs +++ b/crates/pop-drink/src/macros.rs @@ -17,13 +17,13 @@ use crate::last_contract_event; /// /// ```rs /// use drink::devnet::{ -/// Assets, -/// AssetsError::BalanceLow, -/// v0::{ -/// Arithmetic, -/// ArithmeticError::Overflow, -/// BadOrigin -/// }, +/// Assets, +/// AssetsError::BalanceLow, +/// v0::{ +/// Arithmetic, +/// ArithmeticError::Overflow, +/// BadOrigin +/// }, /// }; /// ``` /// @@ -51,50 +51,50 @@ use crate::last_contract_event; /// /// /// Custom error in contract. /// pub enum CustomError { -/// ..., -/// /// Error with status code. -/// StatusCode(u32), +/// ..., +/// /// Error with status code. +/// StatusCode(u32), /// } /// /// impl From for CustomError { -/// /// Converts a `StatusCode` (returned by the api) to a `CustomError`. -/// fn from(value: StatusCode) -> Self { -/// match value { -/// ..., -/// _ => CustomError::StatusCode(value.0), -/// } -/// } +/// /// Converts a `StatusCode` (returned by the api) to a `CustomError`. +/// fn from(value: StatusCode) -> Self { +/// match value { +/// ..., +/// _ => CustomError::StatusCode(value.0), +/// } +/// } /// } /// /// impl From for u32 { -/// /// Converts a `CustomError to a `u32`. -/// // -/// // Required for the `assert_err` macro to assert to `Error`. -/// fn from(value: CustomError) -> Self { -/// match value { -/// ..., -/// CustomError::StatusCode(status_code) => status_code, -/// } -/// } +/// /// Converts a `CustomError to a `u32`. +/// // +/// // Required for the `assert_err` macro to assert to `Error`. +/// fn from(value: CustomError) -> Self { +/// match value { +/// ..., +/// CustomError::StatusCode(status_code) => status_code, +/// } +/// } /// } /// /// - Use `assert_err` in a test. /// /// #[drink::test(sandbox = Pop)] /// fn test_custom_error(mut session: Session) { -/// ... +/// ... /// -/// // Call a contract method that returns a `Result<(), CustomError>`. -/// let result = call::(session, "hello_world", vec![], None); +/// // Call a contract method that returns a `Result<(), CustomError>`. +/// let result = call::(session, "hello_world", vec![], None); /// -/// // Assert the result to the expected error. -/// assert_err!(result, Error::Raw(BadOrigin))); +/// // Assert the result to the expected error. +/// assert_err!(result, Error::Raw(BadOrigin))); /// -/// // Other assertions: -/// ... -/// assert_err!(result, Error::Raw(Arithmetic(Overflow))); -/// ... -/// assert_err!(result, Error::Module(Assets(BalanceLow))); +/// // Other assertions: +/// ... +/// assert_err!(result, Error::Raw(Arithmetic(Overflow))); +/// ... +/// assert_err!(result, Error::Module(Assets(BalanceLow))); /// } /// ``` /// @@ -135,12 +135,12 @@ where /// /// ```rs /// assert_last_contract_event!( -/// &session, -/// Transfer { -/// from: Some(account_id_from_slice(&contract)), -/// to: Some(account_id_from_slice(&BOB)), -/// value, -/// } +/// &session, +/// Transfer { +/// from: Some(account_id_from_slice(&contract)), +/// to: Some(account_id_from_slice(&BOB)), +/// value, +/// } /// ); /// ``` ///