#[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],
state: &mut VariableBytes,
) -> Result<(), ContractError>
pub fn initialize( public_key: &[u8; 32], state: &mut VariableBytes, ) -> Result<(), ContractError>
Returns initial state with a provided public key
Reads state of owner
and returns Ok(())
if authorization succeeds
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: &VariableBytes,
seal: &TxHandlerSeal,
new_state: &mut VariableBytes,
) -> Result<(), ContractError>
pub fn increase_nonce( state: &VariableBytes, seal: &TxHandlerSeal, new_state: &mut VariableBytes, ) -> Result<(), ContractError>
Returns state with increased nonce
Sourcepub fn change_public_key(
state: &VariableBytes,
public_key: &[u8; 32],
new_state: &mut VariableBytes,
) -> Result<(), ContractError>
pub fn change_public_key( state: &VariableBytes, public_key: &[u8; 32], new_state: &mut VariableBytes, ) -> Result<(), ContractError>
Returns state with a changed public key
Trait Implementations§
Source§impl Clone for SimpleWalletBase
impl Clone for SimpleWalletBase
Source§fn clone(&self) -> SimpleWalletBase
fn clone(&self) -> SimpleWalletBase
Returns a copy of the value. Read more
1.0.0 · 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 moreSource§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.const SIZE: u32 = _
Source§unsafe fn from_bytes(bytes: &[u8]) -> Option<&Self>
unsafe fn from_bytes(bytes: &[u8]) -> Option<&Self>
Create a reference to a type, which is represented by provided memory. Read more
impl Copy for SimpleWalletBase
Auto Trait Implementations§
impl Freeze for SimpleWalletBase
impl RefUnwindSafe for SimpleWalletBase
impl Send for SimpleWalletBase
impl Sync for SimpleWalletBase
impl Unpin for SimpleWalletBase
impl UnwindSafe for SimpleWalletBase
Blanket Implementations§
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> IoType for Twhere
T: TrivialType,
impl<T> IoType for Twhere
T: TrivialType,
Source§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 detailsSource§type PointerType = T
type PointerType = T
Pointer with trivial type that this
IoType
representsSource§unsafe fn size_ptr(&self) -> impl Deref<Target = NonNull<u32>>
unsafe fn size_ptr(&self) -> impl Deref<Target = NonNull<u32>>
Pointer to the number of bytes that are currently used to store data. Read more
Source§unsafe fn size_mut_ptr(&mut self) -> impl DerefMut
unsafe fn size_mut_ptr(&mut self) -> impl DerefMut
An exclusive pointer to the number of bytes that are currently used to store data. Read more
Source§unsafe fn capacity_ptr(&self) -> impl Deref<Target = NonNull<u32>>
unsafe fn capacity_ptr(&self) -> impl Deref<Target = NonNull<u32>>
Number of bytes are allocated right now Read more
Source§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
Source§unsafe fn from_mut_ptr<'a>(
ptr: &'a mut NonNull<<T as IoType>::PointerType>,
_size: &'a mut *mut u32,
capacity: u32,
) -> impl DerefMut + 'a
unsafe fn from_mut_ptr<'a>( ptr: &'a mut NonNull<<T as IoType>::PointerType>, _size: &'a mut *mut u32, capacity: u32, ) -> impl DerefMut + 'a
Create a mutable reference to a type, which is represented by provided memory. Read more
Source§unsafe fn as_ptr(
&self,
) -> impl Deref<Target = NonNull<<T as IoType>::PointerType>>
unsafe fn as_ptr( &self, ) -> impl Deref<Target = NonNull<<T as IoType>::PointerType>>
Get a raw pointer to the underlying data with no checks. Read more
Source§unsafe fn as_mut_ptr(&mut self) -> impl DerefMut
unsafe fn as_mut_ptr(&mut self) -> impl DerefMut
Get an exclusive raw pointer to the underlying data with no checks. Read more