Enum escrow_io::EscrowAction
source · pub enum EscrowAction {
Create {
buyer: ActorId,
seller: ActorId,
amount: u128,
},
Deposit(WalletId),
Confirm(WalletId),
Refund(WalletId),
Cancel(WalletId),
Continue(u64),
}
Expand description
An enum to send the program info about what it should do.
After a successful processing of this enum, the program replies with EscrowEvent
.
Variants§
Create
Creates one escrow wallet and replies with its ID.
§Requirements
msg::source()
must bebuyer
orseller
for this wallet.buyer
orseller
mustn’t have the zero address.
On success, returns EscrowEvent::Created
.
Deposit(WalletId)
Makes a deposit from a buyer to an escrow wallet
and changes wallet’s WalletState
to AwaitingConfirmation
.
Transfers tokens to an escrow wallet until a deal is confirmed (by EscrowAction::Confirm
) or cancelled (EscrowAction::Cancel
).
§Requirements
msg::source()
must be a buyer for this wallet.- Wallet mustn’t be paid or closed (that is, wallet’s
WalletState
must beAwaitingDeposit
).
On success, returns EscrowEvent::Deposited
.
Confirm(WalletId)
Confirms a deal by transferring tokens from an escrow wallet
to a seller and changing wallet’s WalletState
to Closed
.
Transfers tokens from an escrow wallet to a seller for this wallet.
§Requirements
msg::source()
must be a buyer for this wallet.- Wallet must be paid and unclosed (that is, wallet’s
WalletState
must beAwaitingDeposit
).
On success, returns EscrowEvent::Confirmed
.
Refund(WalletId)
Refunds tokens from an escrow wallet to a buyer
and changes wallet’s WalletState
back to AwaitingDeposit
(that is, a wallet can be reused).
Refunds tokens from an escrow wallet to a buyer for this wallet.
§Requirements
msg::source()
must be a seller for this wallet.- Wallet must be paid and unclosed (that is, wallet’s
WalletState
must beAwaitingDeposit
).
On success, returns EscrowEvent::Refunded
.
Cancel(WalletId)
Cancels a deal and closes an escrow wallet by changing its WalletState
to Closed
.
§Requirements
msg::source()
must be a buyer or seller for this wallet.- Wallet mustn’t be paid or closed (that is, wallet’s
WalletState
must beAwaitingDeposit
).
On success, returns EscrowEvent::Cancelled
.
Continue(u64)
Continues the transaction if it fails due to lack of gas or due to an error in the token contract.
§Requirements:
transaction_id
should exists intransactions
table;
When transaction already processed replies with EscrowEvent::TransactionProcessed
.
Trait Implementations§
source§impl Clone for EscrowAction
impl Clone for EscrowAction
source§fn clone(&self) -> EscrowAction
fn clone(&self) -> EscrowAction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Decode for EscrowAction
impl Decode for EscrowAction
source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy ) -> Result<Self, Error>
§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
§fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
§fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
source§impl Encode for EscrowAction
impl Encode for EscrowAction
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy )
§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl TypeInfo for EscrowAction
impl TypeInfo for EscrowAction
impl EncodeLike for EscrowAction
Auto Trait Implementations§
impl Freeze for EscrowAction
impl RefUnwindSafe for EscrowAction
impl Send for EscrowAction
impl Sync for EscrowAction
impl Unpin for EscrowAction
impl UnwindSafe for EscrowAction
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
§impl<T> DecodeAll for Twhere
T: Decode,
impl<T> DecodeAll for Twhere
T: Decode,
§fn decode_all(input: &mut &[u8]) -> Result<T, Error>
fn decode_all(input: &mut &[u8]) -> Result<T, Error>
Self
and consume all of the given input data. Read more§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
§impl<T> KeyedVec for Twhere
T: Codec,
impl<T> KeyedVec for Twhere
T: Codec,
§fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>
fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>
Self
prepended by given slice.