pub struct PartialTransactionV2Builder { /* private fields */ }
Expand description
A builder for a SignedPartialTransactionV2
.
This should be used in the following order:
- Configure the root subintent:
- Set the
intent_header
- Optionally, set the
message
- Optionally, add one or more signed partial transaction children
add_signed_child
. These can themseleves be created with thePartialTransactionV2Builder
methods [build_with_names()
][PartialTransactionV2Builder::build_with_names] orbuild
. - Set the manifest with
manifest_builder
.
- Set the
- Sign the root subintent zero or more times:
- Use methods
sign
ormulti_sign
add_signature
- Use methods
- Build:
- Use method
build
, [build_no_validate
][Self::build_no_validate],build_minimal
or [build_minimal_no_validate
][Self::build_minimal_no_validate]
- Use method
The error messages aren’t great if used out of order. In future, this may become a state-machine style builder, to catch more errors at compile time.
Implementations§
Source§impl PartialTransactionV2Builder
impl PartialTransactionV2Builder
pub fn new() -> PartialTransactionV2Builder
pub fn then( self, next: impl FnOnce(PartialTransactionV2Builder) -> PartialTransactionV2Builder, ) -> PartialTransactionV2Builder
Sourcepub fn add_signed_child(
self,
name: impl AsRef<str>,
signed_partial_transaction: impl ResolvableSignedPartialTransaction,
) -> PartialTransactionV2Builder
pub fn add_signed_child( self, name: impl AsRef<str>, signed_partial_transaction: impl ResolvableSignedPartialTransaction, ) -> PartialTransactionV2Builder
When used with the manifest_builder
method, the provided name and hash
are provided automatically via use_child
at the start of manifest creation.
When used with the manifest
method, the provided name is simply ignored - names
are returned from the provided manifest.
Sourcepub fn manifest_builder(
self,
build_manifest: impl FnOnce(ManifestBuilder<SubintentManifestV2>) -> ManifestBuilder<SubintentManifestV2>,
) -> PartialTransactionV2Builder
pub fn manifest_builder( self, build_manifest: impl FnOnce(ManifestBuilder<SubintentManifestV2>) -> ManifestBuilder<SubintentManifestV2>, ) -> PartialTransactionV2Builder
If the intent has any children, you should call add_signed_child
first.
These children will get added to the manifest for you, with the corresponding names.
You may also want to try manifest_builder_with_lookup
.
Sourcepub fn manifest_builder_with_lookup(
self,
build_manifest: impl FnOnce(ManifestBuilder<SubintentManifestV2>, ManifestNameLookup) -> ManifestBuilder<SubintentManifestV2>,
) -> PartialTransactionV2Builder
pub fn manifest_builder_with_lookup( self, build_manifest: impl FnOnce(ManifestBuilder<SubintentManifestV2>, ManifestNameLookup) -> ManifestBuilder<SubintentManifestV2>, ) -> PartialTransactionV2Builder
If the intent has any children, you should call add_signed_child
first.
These children will get added to the manifest for you, with the corresponding names.
Sourcepub fn manifest(
self,
manifest: SubintentManifestV2,
) -> PartialTransactionV2Builder
pub fn manifest( self, manifest: SubintentManifestV2, ) -> PartialTransactionV2Builder
Panics:
- If called with a manifest which references different children to those provided by
add_signed_child
.
pub fn message(self, message: MessageV2) -> PartialTransactionV2Builder
pub fn intent_header( self, intent_header: IntentHeaderV2, ) -> PartialTransactionV2Builder
pub fn create_subintent(&mut self) -> &SubintentV2
pub fn create_prepared_subintent(&mut self) -> &PreparedSubintentV2
pub fn subintent_hash(&mut self) -> SubintentHash
pub fn sign<S>(self, signer: S) -> PartialTransactionV2Builderwhere
S: Signer,
pub fn multi_sign<S>(
self,
signers: impl IntoIterator<Item = S>,
) -> PartialTransactionV2Builderwhere
S: Signer,
pub fn add_signature( self, signature: SignatureWithPublicKeyV1, ) -> PartialTransactionV2Builder
Sourcepub fn build(self) -> DetailedSignedPartialTransactionV2
pub fn build(self) -> DetailedSignedPartialTransactionV2
Builds a DetailedSignedPartialTransactionV2
, including the SignedPartialTransactionV2
and other useful data.
§Panics
- Panics if any required part of the partial transaction has not been provided.
- Panics if the built transaction cannot be prepared.
Unlike TransactionV2Builder
, build()
does not validate the partial transaction, to save
lots duplicate work when building a full transaction from layers of partial transaction. If you wish,
you can opt into validation with build_and_validate()
.
Sourcepub fn build_and_validate(self) -> DetailedSignedPartialTransactionV2
pub fn build_and_validate(self) -> DetailedSignedPartialTransactionV2
Builds a DetailedSignedPartialTransactionV2
, including the SignedPartialTransactionV2
and other useful data.
§Panics
- Panics if any required part of the partial transaction has not been provided.
- Panics if the built transaction does not pass validation with the latest validator.
You can use build()
to skip this validation.
Sourcepub fn build_minimal(self) -> SignedPartialTransactionV2
pub fn build_minimal(self) -> SignedPartialTransactionV2
Builds the SignedPartialTransactionV2
.
You may wish to use [build_detailed()
][Self::build_detailed] to get the hashes, or to
preserve the names used for manifest variables in the root and non-root subintents.
Unlike TransactionV2Builder
, build()
does not validate the partial transaction, to save
lots duplicate work when building a full transaction from layers of partial transaction. If you wish,
you can opt into validation with build_and_validate()
.
Sourcepub fn build_minimal_and_validate(self) -> SignedPartialTransactionV2
pub fn build_minimal_and_validate(self) -> SignedPartialTransactionV2
Builds and validates the SignedPartialTransactionV2
.
You may wish to use build()
to get the hashes, or to
preserve the names used for manifest variables in the root and non-root subintents.
§Panics
Panics if the built transaction does not pass validation with the latest validator.
You can use build_minimal()
to skip this validation.
Trait Implementations§
Source§impl Clone for PartialTransactionV2Builder
impl Clone for PartialTransactionV2Builder
Source§fn clone(&self) -> PartialTransactionV2Builder
fn clone(&self) -> PartialTransactionV2Builder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Default for PartialTransactionV2Builder
impl Default for PartialTransactionV2Builder
Source§fn default() -> PartialTransactionV2Builder
fn default() -> PartialTransactionV2Builder
Auto Trait Implementations§
impl Freeze for PartialTransactionV2Builder
impl RefUnwindSafe for PartialTransactionV2Builder
impl Send for PartialTransactionV2Builder
impl Sync for PartialTransactionV2Builder
impl Unpin for PartialTransactionV2Builder
impl UnwindSafe for PartialTransactionV2Builder
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, U> ContextualTryInto<U> for Twhere
U: ContextualTryFrom<T>,
impl<T, U> ContextualTryInto<U> for Twhere
U: ContextualTryFrom<T>,
type Error = <U as ContextualTryFrom<T>>::Error
type Context = <U as ContextualTryFrom<T>>::Context
fn contextual_try_into( self, context: &<U as ContextualTryFrom<T>>::Context, ) -> Result<U, <U as ContextualTryFrom<T>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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