pub struct TransactionPayloadBuilder { /* private fields */ }
Expand description
Builder for payload to be used with TxHandler
(primarily for SimpleWallet
).
Decoding can be done with TransactionPayloadDecoder
Implementations§
Source§impl TransactionPayloadBuilder
impl TransactionPayloadBuilder
Sourcepub fn with_method_call<Args>(
&mut self,
contract: &Address,
external_args: &Args,
method_context: TransactionMethodContext,
slot_output_index: &[Option<u8>],
input_output_index: &[Option<u8>],
) -> Result<(), TransactionPayloadBuilderError<'static>>where
Args: ExternalArgs,
pub fn with_method_call<Args>(
&mut self,
contract: &Address,
external_args: &Args,
method_context: TransactionMethodContext,
slot_output_index: &[Option<u8>],
input_output_index: &[Option<u8>],
) -> Result<(), TransactionPayloadBuilderError<'static>>where
Args: ExternalArgs,
Add method call to the payload.
The wallet will call this method in addition order.
slot_output_index
and input_output_index
are used for referencing earlier outputs as
slots or inputs of this method, its values are optional, see TransactionInput
for more
details.
Sourcepub unsafe fn with_method_call_untyped<'a>(
&mut self,
contract: &Address,
external_args: &NonNull<*const c_void>,
method_metadata: &'a [u8],
method_fingerprint: &MethodFingerprint,
method_context: TransactionMethodContext,
slot_output_index: &[Option<u8>],
input_output_index: &[Option<u8>],
) -> Result<(), TransactionPayloadBuilderError<'a>>
pub unsafe fn with_method_call_untyped<'a>( &mut self, contract: &Address, external_args: &NonNull<*const c_void>, method_metadata: &'a [u8], method_fingerprint: &MethodFingerprint, method_context: TransactionMethodContext, slot_output_index: &[Option<u8>], input_output_index: &[Option<u8>], ) -> Result<(), TransactionPayloadBuilderError<'a>>
Other than unsafe API, this method is identical to Self::with_method_call()
.
§Safety
external_args
must correspond to method_metadata
and method_fingerprint
. Outputs are
never read from external_args
and inputs that have corresponding input_output_index
are not read either.
Sourcepub fn into_aligned_bytes(self) -> Vec<u128>
pub fn into_aligned_bytes(self) -> Vec<u128>
Returns 16-byte aligned bytes.
The contents is a concatenated sequence of method calls with their arguments. All data
structures are correctly aligned in the returned byte buffer with 0
used as padding when
necessary.
Each method is serialized in the following way:
- Contract to call:
Address
- Fingerprint of the method to call:
MethodFingerprint
- Method context:
TransactionMethodContext
- Number of
#[slot]
arguments:u8
- For each
#[slot]
argument:TransactionSlot
asu8
- Number of
#[input]
arguments:u8
- For each
#[input]
argument:TransactionInput
for each#[input]
argument asu8
- Number of
#[output]
arguments:u8
- For each
TransactionSlot
, whose type isTransactionSlotType::Address
: - For each
TransactionInput
, whose type isTransactionInputType::Value
:- Input size as little-endian
u32
followed by the input itself
- Input size as little-endian
- For each
#[output]
:- recommended capacity as little-endian
u32
followed by alignment power asu8
(NonZeroU8::ilog2(alignment)
)
- recommended capacity as little-endian
Trait Implementations§
Source§impl Clone for TransactionPayloadBuilder
impl Clone for TransactionPayloadBuilder
Source§fn clone(&self) -> TransactionPayloadBuilder
fn clone(&self) -> TransactionPayloadBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TransactionPayloadBuilder
impl Debug for TransactionPayloadBuilder
Auto Trait Implementations§
impl Freeze for TransactionPayloadBuilder
impl RefUnwindSafe for TransactionPayloadBuilder
impl Send for TransactionPayloadBuilder
impl Sync for TransactionPayloadBuilder
impl Unpin for TransactionPayloadBuilder
impl UnwindSafe for TransactionPayloadBuilder
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
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>
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>
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