pub trait SimpleWalletBaseExt {
// Required methods
fn simple_wallet_base_initialize(
&self,
contract: Address,
public_key: &[u8; 32],
) -> Result<WalletState, ContractError>;
fn simple_wallet_base_authorize(
&self,
contract: Address,
state: &WalletState,
header: &TransactionHeader,
read_slots: &TxHandlerSlots,
write_slots: &TxHandlerSlots,
payload: &TxHandlerPayload,
seal: &TxHandlerSeal,
) -> Result<(), ContractError>;
fn simple_wallet_base_execute(
&mut self,
method_context: MethodContext,
contract: Address,
header: &TransactionHeader,
read_slots: &TxHandlerSlots,
write_slots: &TxHandlerSlots,
payload: &TxHandlerPayload,
seal: &TxHandlerSeal,
) -> Result<(), ContractError>;
fn simple_wallet_base_increase_nonce(
&self,
contract: Address,
state: &WalletState,
) -> Result<WalletState, ContractError>;
fn simple_wallet_base_change_public_key(
&self,
contract: Address,
state: &WalletState,
public_key: &[u8; 32],
) -> Result<WalletState, ContractError>;
}
Expand description
Extension trait that provides helper methods for calling SimpleWalletBase
’s methods on Env
for convenience purposes
Required Methods§
Sourcefn simple_wallet_base_initialize(
&self,
contract: Address,
public_key: &[u8; 32],
) -> Result<WalletState, ContractError>
fn simple_wallet_base_initialize( &self, contract: Address, 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
Sourcefn simple_wallet_base_execute(
&mut self,
method_context: MethodContext,
contract: Address,
header: &TransactionHeader,
read_slots: &TxHandlerSlots,
write_slots: &TxHandlerSlots,
payload: &TxHandlerPayload,
seal: &TxHandlerSeal,
) -> Result<(), ContractError>
fn simple_wallet_base_execute( &mut self, method_context: MethodContext, contract: Address, 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.
Sourcefn simple_wallet_base_increase_nonce(
&self,
contract: Address,
state: &WalletState,
) -> Result<WalletState, ContractError>
fn simple_wallet_base_increase_nonce( &self, contract: Address, state: &WalletState, ) -> Result<WalletState, ContractError>
Returns state with increased nonce
Sourcefn simple_wallet_base_change_public_key(
&self,
contract: Address,
state: &WalletState,
public_key: &[u8; 32],
) -> Result<WalletState, ContractError>
fn simple_wallet_base_change_public_key( &self, contract: Address, state: &WalletState, public_key: &[u8; 32], ) -> Result<WalletState, ContractError>
Returns a new state with a changed public key