Struct ProgrammableTransactionBuilder

Source
pub struct ProgrammableTransactionBuilder { /* private fields */ }
Expand description

Builder for a ProgrammableTransaction.

Implementations§

Source§

impl ProgrammableTransactionBuilder

Base API.

Source

pub fn new() -> Self

Source

pub fn finish(self) -> ProgrammableTransaction

Source

pub fn pure<T: Serialize + ?Sized>(&mut self, value: &T) -> Result<Argument>

Potentially adds a pure argument to the PTB.

May not create a new PTB input if a previous one already has the same contents.

Source

pub fn force_separate_pure<T: Serialize>( &mut self, value: T, ) -> Result<Argument>

Like Self::pure but forces a separate input entry

Source

pub fn pure_bytes(&mut self, bytes: Vec<u8>, force_separate: bool) -> Argument

Adds a pure argument to the PTB.

§Arguments
  • bytes: the BCS-serialized contents of the argument
  • force_separate: whether to force a separate input argument to the PTB, else the builder re-uses a previously declared input argument if it has the same contents.
Source

pub fn obj(&mut self, obj_arg: ObjectArg) -> Result<Argument>

Adds an object input to the PTB, returning the corresponding argument which can be used in the body.

May fail if overriding a previously declared input.

Source

pub fn command(&mut self, command: impl Into<Command>) -> Argument

Add a command to the PTB.

This will come after any commands that were previously declared.

Source§

impl ProgrammableTransactionBuilder

Extensions to the base API.

Source

pub fn split_coins_into_vec( &mut self, coin: Argument, amounts: Vec<Argument>, ) -> Vec<Argument>

Like .command(Command::SplitCoins(coin_arg, balances)), but also takes care of unpacking each entry in the returned vector as its own Argument.

§Panics

Panics if the balances input vector has a length that exceeds u16::MAX.

Trait Implementations§

Source§

impl Clone for ProgrammableTransactionBuilder

Source§

fn clone(&self) -> ProgrammableTransactionBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProgrammableTransactionBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProgrammableTransactionBuilder

Source§

fn default() -> ProgrammableTransactionBuilder

Returns the “default value” for a type. Read more
Source§

impl From<ProgrammableTransactionBuilder> for ProgrammableTransaction

Source§

fn from(value: ProgrammableTransactionBuilder) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<ProgrammableTransaction> for ProgrammableTransactionBuilder

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(_: ProgrammableTransaction) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.