#[macro_export]
macro_rules! imports {
() => {
use core::ops::{
Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div,
DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
SubAssign,
};
use dharitri_sc::{
abi::TypeAbi,
api::{
BigFloatApi, BigIntApi, BlockchainApi, BlockchainApiImpl, CallValueApi,
CallValueApiImpl, CryptoApi, CryptoApiImpl, EllipticCurveApi, ErrorApi,
ErrorApiImpl, LogApi, LogApiImpl, ManagedTypeApi, PrintApi, PrintApiImpl, SendApi,
SendApiImpl,
},
arrayvec::ArrayVec,
codec::{
multi_types::*, DecodeError, IntoMultiValue, NestedDecode, NestedEncode, TopDecode,
TopEncode,
},
contract_base::{ContractBase, ProxyObjBase},
err_msg,
dcdt::*,
io::*,
non_zero_usize,
non_zero_util::*,
require, require_old, sc_error, sc_format, sc_panic, sc_print,
storage::mappers::*,
types::{
SCResult::{Err, Ok},
*,
},
};
};
}
#[macro_export]
macro_rules! derive_imports {
() => {
use dharitri_sc::{
codec,
codec::derive::{
NestedDecode, NestedEncode, TopDecode, TopDecodeOrDefault, TopEncode,
TopEncodeOrDefault,
},
derive::{ManagedVecItem, TypeAbi},
};
};
}
#[macro_export]
macro_rules! sc_error {
($s:expr) => {
dharitri_sc::types::SCResult::Err(dharitri_sc::types::StaticSCError::from($s)).into()
};
}
#[macro_export]
macro_rules! require_old {
($expression:expr, $error_msg:expr) => {
if (!($expression)) {
return dharitri_sc::sc_error!($error_msg);
}
};
}
#[macro_export]
macro_rules! sc_panic {
($msg:tt, $($arg:expr),+ $(,)?) => {{
let mut ___buffer___ =
dharitri_sc::types::ManagedBufferCachedBuilder::<Self::Api>::new_from_slice(&[]);
dharitri_sc::derive::format_receiver_args!(___buffer___, $msg, $($arg),+);
dharitri_sc::contract_base::ErrorHelper::<Self::Api>::signal_error_with_message(___buffer___.into_managed_buffer());
}};
($msg:expr $(,)?) => {
dharitri_sc::contract_base::ErrorHelper::<Self::Api>::signal_error_with_message($msg);
};
}
#[macro_export]
macro_rules! require {
($expression:expr, $($msg_tokens:tt),+ $(,)?) => {
if (!($expression)) {
dharitri_sc::sc_panic!($($msg_tokens),+);
}
};
}
#[macro_export]
macro_rules! sc_print {
($msg:tt, $($arg:expr),* $(,)?) => {{
let mut ___buffer___ =
<<Self::Api as dharitri_sc::api::PrintApi>::PrintApiImpl as dharitri_sc::api::PrintApiImpl>::Buffer::default();
dharitri_sc::derive::format_receiver_args!(___buffer___, $msg, $($arg),*);
<<Self::Api as dharitri_sc::api::PrintApi>::PrintApiImpl as dharitri_sc::api::PrintApiImpl>::print_buffer(
&<Self::Api as dharitri_sc::api::PrintApi>::print_api_impl(),
___buffer___,
);
}};
}
#[macro_export]
macro_rules! sc_format {
($msg:tt, $($arg:expr),+ $(,)?) => {{
let mut ___buffer___ =
dharitri_sc::types::ManagedBufferCachedBuilder::<Self::Api>::new_from_slice(&[]);
dharitri_sc::derive::format_receiver_args!(___buffer___, $msg, $($arg),+);
___buffer___.into_managed_buffer()
}};
($msg:expr $(,)?) => {{
dharitri_sc::types::ManagedBuffer::new_from_bytes($msg.as_bytes())
}};
}
#[deprecated(
since = "0.16.0",
note = "The `?` operator can now be used on `SCResult`, please use it instead."
)]
#[macro_export]
macro_rules! sc_try {
($s:expr) => {
match $s {
dharitri_sc::types::SCResult::Ok(t) => t,
dharitri_sc::types::SCResult::Err(e) => {
return dharitri_sc::types::SCResult::Err(e);
},
}
};
}
#[deprecated(
since = "0.26.0",
note = "Replace with the `#[only_owner]` attribute that can be placed on an endpoint. That one is more compact and shows up in the ABI."
)]
#[macro_export]
macro_rules! only_owner {
($trait_self: expr, $error_msg:expr) => {
if ($trait_self.blockchain().get_caller() != $trait_self.blockchain().get_owner_address()) {
return sc_error!($error_msg);
}
};
}
#[macro_export]
macro_rules! non_zero_usize {
($input: expr, $error_msg:expr) => {
NonZeroUsize::new($input).unwrap_or_else(|| sc_panic!($error_msg))
};
}