Skip to content

Commit

Permalink
Exposed a method for adding a roob subintent signer to the previeww
Browse files Browse the repository at this point in the history
partial tx
  • Loading branch information
0xOmarA committed Nov 12, 2024
1 parent 2bdefe1 commit 401d1b0
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct PreviewPartialTransactionV2Builder {
root_subintent_header: Option<IntentHeaderV2>,
root_subintent_message: MessageV2,
root_subintent_manifest: Option<TransactionManifestV2>,
root_subintent_signers: Vec<PublicKey>,
}

#[uniffi::export]
Expand All @@ -35,6 +36,7 @@ impl PreviewPartialTransactionV2Builder {
root_subintent_header: Default::default(),
root_subintent_message: Default::default(),
root_subintent_manifest: Default::default(),
root_subintent_signers: Default::default(),
})
}

Expand Down Expand Up @@ -69,14 +71,20 @@ impl PreviewPartialTransactionV2Builder {
})
}

pub fn prepare_for_signing(
pub fn add_root_subintent_signer(
self: Arc<Self>,
) -> Result<Arc<PreviewPartialTransactionV2>> {
signer: PublicKey,
) -> Arc<Self> {
self.with_builder(|builder| builder.root_subintent_signers.push(signer))
}

pub fn build(self: Arc<Self>) -> Result<Arc<PreviewPartialTransactionV2>> {
// Deconstructing the builder.
let PreviewPartialTransactionV2Builder {
children_with_signers,
root_subintent_header: Some(header),
root_subintent_message: message,
root_subintent_signers,
root_subintent_manifest:
Some(TransactionManifestV2 {
instructions,
Expand Down Expand Up @@ -120,7 +128,7 @@ impl PreviewPartialTransactionV2Builder {
// Constructing the signed partial transaction
let preview_partial_transaction = PreviewPartialTransactionV2 {
partial_transaction: Arc::new(partial_transaction),
root_subintent_signers: Default::default(),
root_subintent_signers,
non_root_subintent_signers: children_with_signers
.iter()
.flat_map(|child| {
Expand Down

0 comments on commit 401d1b0

Please sign in to comment.