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() -> Self
pub fn then(self, next: impl FnOnce(Self) -> Self) -> Self
Sourcepub fn add_signed_child(
self,
name: impl AsRef<str>,
signed_partial_transaction: impl ResolvableSignedPartialTransaction,
) -> Self
pub fn add_signed_child( self, name: impl AsRef<str>, signed_partial_transaction: impl ResolvableSignedPartialTransaction, ) -> Self
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(SubintentManifestV2Builder) -> SubintentManifestV2Builder,
) -> Self
pub fn manifest_builder( self, build_manifest: impl FnOnce(SubintentManifestV2Builder) -> SubintentManifestV2Builder, ) -> Self
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(SubintentManifestV2Builder, ManifestNameLookup) -> SubintentManifestV2Builder,
) -> Self
pub fn manifest_builder_with_lookup( self, build_manifest: impl FnOnce(SubintentManifestV2Builder, ManifestNameLookup) -> SubintentManifestV2Builder, ) -> Self
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) -> Self
pub fn manifest(self, manifest: SubintentManifestV2) -> Self
Panics:
- If called with a manifest which references different children to those provided by
add_signed_child
.
pub fn message(self, message: MessageV2) -> Self
pub fn intent_header(self, intent_header: IntentHeaderV2) -> Self
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: Signer>(self, signer: S) -> Self
pub fn multi_sign<S: Signer>(self, signers: impl IntoIterator<Item = S>) -> Self
pub fn add_signature(self, signature: SignatureWithPublicKeyV1) -> Self
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 more