#[repr(C)]pub struct SimpleWalletBase;Expand description
A simple wallet contract base contract to be used by other contracts.
See the module description for details.
Implementations§
Source§impl SimpleWalletBase
impl SimpleWalletBase
Sourcepub fn initialize(public_key: &[u8; 32]) -> Result<WalletState, ContractError>
pub fn initialize(public_key: &[u8; 32]) -> Result<WalletState, ContractError>
Returns initial state with a provided public key
Reads state of owner and returns Ok(()) if authorization succeeds.
seal must hold exactly the bytes of a Seal.
Sourcepub fn execute(
env: &mut Env<'_>,
header: &TransactionHeader,
read_slots: &TxHandlerSlots,
write_slots: &TxHandlerSlots,
payload: &TxHandlerPayload,
seal: &TxHandlerSeal,
) -> Result<(), ContractError>
pub fn execute( env: &mut Env<'_>, header: &TransactionHeader, read_slots: &TxHandlerSlots, write_slots: &TxHandlerSlots, payload: &TxHandlerPayload, seal: &TxHandlerSeal, ) -> Result<(), ContractError>
Executes provided transactions in the payload.
IMPORTANT:
- must only be called with trusted input, for example, successful signature verification
in
SimpleWalletBase::authorize()implies transaction was seen and verified by the user - remember to also
SimpleWalletBase::increase_nonce()afterward unless there is a very good reason not to (like when wallet was replaced with another implementation containing a different state)
The caller must set themselves as a context or else error will be returned.
Sourcepub fn increase_nonce(state: &WalletState) -> Result<WalletState, ContractError>
pub fn increase_nonce(state: &WalletState) -> Result<WalletState, ContractError>
Returns state with increased nonce
Sourcepub fn change_public_key(
state: &WalletState,
public_key: &[u8; 32],
) -> Result<WalletState, ContractError>
pub fn change_public_key( state: &WalletState, public_key: &[u8; 32], ) -> Result<WalletState, ContractError>
Returns a new state with a changed public key
Trait Implementations§
impl AnyBitPatternMarker for SimpleWalletBase
Source§impl Clone for SimpleWalletBase
impl Clone for SimpleWalletBase
Source§fn clone(&self) -> SimpleWalletBase
fn clone(&self) -> SimpleWalletBase
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Contract for SimpleWalletBase
impl Contract for SimpleWalletBase
Source§const MAIN_CONTRACT_METADATA: &[u8]
const MAIN_CONTRACT_METADATA: &[u8]
Main contract metadata, see
ContractMetadataKind for encoding details. Read moreimpl Copy for SimpleWalletBase
Source§impl Debug for SimpleWalletBase
impl Debug for SimpleWalletBase
Source§impl TrivialType for SimpleWalletBase
impl TrivialType for SimpleWalletBase
Source§const METADATA: &[u8]
const METADATA: &[u8]
Data structure metadata in binary form, describing shape and types of the contents, see
[
IoTypeMetadataKind] for encoding details.Source§fn try_from_bytes_unaligned(bytes: &[u8]) -> Option<(&Unaligned<Self>, &[u8])>
fn try_from_bytes_unaligned(bytes: &[u8]) -> Option<(&Unaligned<Self>, &[u8])>
Parse the beginning of
bytes, which don’t need to be aligned. Read moreconst SIZE: u32 = _
§final fn try_from_bytes(bytes: &[u8]) -> Option<(&Self, &[u8])>
final fn try_from_bytes(bytes: &[u8]) -> Option<(&Self, &[u8])>
Parse the beginning of aligned
bytes, returns the value and the remaining bytes. Read more§final fn try_from_bytes_exact(bytes: &[u8]) -> Option<&Self>
final fn try_from_bytes_exact(bytes: &[u8]) -> Option<&Self>
Like [
Self::try_from_bytes()], but returns None if there are more bytes than the value§final fn try_from_bytes_mut(bytes: &mut [u8]) -> Option<(&mut Self, &mut [u8])>
final fn try_from_bytes_mut(bytes: &mut [u8]) -> Option<(&mut Self, &mut [u8])>
Like [
Self::try_from_bytes()], but returns an exclusive reference. Read more§final fn try_read_unaligned(bytes: &[u8]) -> Option<(Self, &[u8])>
final fn try_read_unaligned(bytes: &[u8]) -> Option<(Self, &[u8])>
Read a copy from the beginning of
bytes, which don’t need to be aligned, returns the value
and the remaining bytes§final fn try_read_unaligned_exact(bytes: &[u8]) -> Option<Self>
final fn try_read_unaligned_exact(bytes: &[u8]) -> Option<Self>
Like [
Self::try_read_unaligned()], but returns None if there are more bytes than the
value§final unsafe fn read_unaligned(bytes: &[u8]) -> Option<Self>
final unsafe fn read_unaligned(bytes: &[u8]) -> Option<Self>
Read unaligned value from memory. Read more
§final unsafe fn read_unaligned_unchecked(bytes: &[u8]) -> Self
final unsafe fn read_unaligned_unchecked(bytes: &[u8]) -> Self
Similar to [
Self::read_unaligned()], but doesn’t do any checks at all. Read more§final unsafe fn from_bytes(bytes: &[u8]) -> Option<&Self>
final unsafe fn from_bytes(bytes: &[u8]) -> Option<&Self>
Create a reference to a type, which is represented by provided memory. Read more
§final unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self
final unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self
Similar to [
Self::from_bytes()], but doesn’t do any checks at all. Read more§final unsafe fn from_bytes_mut(bytes: &mut [u8]) -> Option<&mut Self>
final unsafe fn from_bytes_mut(bytes: &mut [u8]) -> Option<&mut Self>
Create a mutable reference to a type, which is represented by provided memory. Read more
§final unsafe fn from_bytes_mut_unchecked(bytes: &mut [u8]) -> &mut Self
final unsafe fn from_bytes_mut_unchecked(bytes: &mut [u8]) -> &mut Self
Similar to [
Self::from_bytes_mut()], but doesn’t do any checks at all. Read more§final fn as_bytes(&self) -> &[u8; ab_io_type::trivial_type::SIZE_OF::<Self>]
final fn as_bytes(&self) -> &[u8; ab_io_type::trivial_type::SIZE_OF::<Self>]
Access the underlying byte representation of a data structure
§final unsafe fn as_bytes_mut(
&mut self,
) -> &mut [u8; ab_io_type::trivial_type::SIZE_OF::<Self>]
final unsafe fn as_bytes_mut( &mut self, ) -> &mut [u8; ab_io_type::trivial_type::SIZE_OF::<Self>]
Access the underlying mutable byte representation of a data structure. Read more
Auto Trait Implementations§
impl Freeze for SimpleWalletBase
impl RefUnwindSafe for SimpleWalletBase
impl Send for SimpleWalletBase
impl Sync for SimpleWalletBase
impl Unpin for SimpleWalletBase
impl UnsafeUnpin for SimpleWalletBase
impl UnwindSafe for SimpleWalletBase
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: TrivialType + AnyBitPatternMarker,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IoType for Twhere
T: TrivialType,
impl<T> IoType for Twhere
T: TrivialType,
§const METADATA: &'static [u8] = T::METADATA
const METADATA: &'static [u8] = T::METADATA
Data structure metadata in binary form, describing shape and types of the contents, see
IoTypeMetadataKind for encoding details§type PointerType = T
type PointerType = T
Pointer with a trivial type that this
IoType represents§unsafe fn from_ptr<'a>(
ptr: &'a NonNull<<T as IoType>::PointerType>,
size: &'a u32,
capacity: u32,
) -> impl Deref<Target = T> + 'a
unsafe fn from_ptr<'a>( ptr: &'a NonNull<<T as IoType>::PointerType>, size: &'a u32, capacity: u32, ) -> impl Deref<Target = T> + 'a
Create a reference to a type, which is represented by provided memory. Read more
§unsafe fn from_mut_ptr<'a>(
ptr: &'a mut NonNull<<T as IoType>::PointerType>,
_size: &'a mut u32,
capacity: u32,
) -> impl DerefMut + 'a
unsafe fn from_mut_ptr<'a>( ptr: &'a mut NonNull<<T as IoType>::PointerType>, _size: &'a mut u32, capacity: u32, ) -> impl DerefMut + 'a
Create a mutable reference to a type, which is represented by provided memory. Read more
§unsafe fn try_from_ptr<'a>(
ptr: &'a NonNull<<T as IoType>::PointerType>,
size: &'a u32,
capacity: u32,
) -> Option<impl Deref<Target = T> + 'a>
unsafe fn try_from_ptr<'a>( ptr: &'a NonNull<<T as IoType>::PointerType>, size: &'a u32, capacity: u32, ) -> Option<impl Deref<Target = T> + 'a>
Create a reference to a type, which is represented by provided memory, if the memory holds a
valid value. Read more
§unsafe fn try_from_mut_ptr<'a>(
ptr: &'a mut NonNull<<T as IoType>::PointerType>,
size: &'a mut u32,
capacity: u32,
) -> Option<impl DerefMut + 'a>
unsafe fn try_from_mut_ptr<'a>( ptr: &'a mut NonNull<<T as IoType>::PointerType>, size: &'a mut u32, capacity: u32, ) -> Option<impl DerefMut + 'a>
Like [
Self::try_from_ptr()], but returns an exclusive reference. Read more§fn as_ptr(&self) -> NonNull<<T as IoType>::PointerType>
fn as_ptr(&self) -> NonNull<<T as IoType>::PointerType>
Get a raw pointer to the underlying data. Read more
§fn as_mut_ptr(&mut self) -> NonNull<<T as IoType>::PointerType>
fn as_mut_ptr(&mut self) -> NonNull<<T as IoType>::PointerType>
Get an exclusive raw pointer to the underlying data. Read more
§impl<T> IoTypeMut for Twhere
T: IoType,
impl<T> IoTypeMut for Twhere
T: IoType,
§fn io_type_mut(&mut self) -> &mut <T as IoTypeMut>::Target
fn io_type_mut(&mut self) -> &mut <T as IoTypeMut>::Target
Exclusive access to the value
§impl<Arg> OutputArg<<Arg as IoTypeMut>::Target> for Argwhere
Arg: IoTypeMut,
<<Arg as IoTypeMut>::Target as IoType>::PointerType: AnyBitPattern,
impl<Arg> OutputArg<<Arg as IoTypeMut>::Target> for Argwhere
Arg: IoTypeMut,
<<Arg as IoTypeMut>::Target as IoType>::PointerType: AnyBitPattern,
§fn as_raw_output(
&mut self,
) -> (NonNull<<<Arg as IoTypeMut>::Target as IoType>::PointerType>, u32, u32)
fn as_raw_output( &mut self, ) -> (NonNull<<<Arg as IoTypeMut>::Target as IoType>::PointerType>, u32, u32)
Pointer to the contents, size and capacity to give to a call
§unsafe fn set_output_size(&mut self, size: u32)
unsafe fn set_output_size(&mut self, size: u32)
Set the size that a successful call reported. Read more