From 6b99c0e0a9ef70ec7b65392726de2c2e751dbea3 Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Thu, 22 Feb 2024 10:47:31 -0500 Subject: [PATCH] =?UTF-8?q?transaction:=20=F0=9F=9A=AA=20re=C3=ABxport=20`?= =?UTF-8?q?TransactionPlan`=20(#3864)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit as the crate's documentation points out, `TransactionPlan` is one of the critical types provided by this library. let's `pub use` it in `lib.rs`, alongside `Transaction`. --- crates/bin/pcli/src/command/tx/proposal.rs | 2 +- crates/bin/pcli/src/network.rs | 4 +--- crates/bin/pcli/src/terminal.rs | 2 +- crates/bin/pclientd/tests/network_integration.rs | 13 ++++++------- .../core/app/src/action_handler/actions/submit.rs | 4 +--- crates/core/transaction/src/lib.rs | 4 ++-- crates/core/transaction/src/plan/auth.rs | 2 +- crates/custody/src/policy.rs | 2 +- crates/custody/src/pre_auth.rs | 2 +- crates/custody/src/request.rs | 2 +- crates/custody/src/soft_kms.rs | 2 +- crates/custody/src/threshold.rs | 2 +- crates/custody/src/threshold/sign.rs | 2 +- crates/view/src/client.rs | 3 +-- crates/view/src/service.rs | 2 +- crates/wallet/src/build.rs | 2 +- crates/wallet/src/plan.rs | 2 +- 17 files changed, 23 insertions(+), 29 deletions(-) diff --git a/crates/bin/pcli/src/command/tx/proposal.rs b/crates/bin/pcli/src/command/tx/proposal.rs index e2b9574b1e..826f19b0e8 100644 --- a/crates/bin/pcli/src/command/tx/proposal.rs +++ b/crates/bin/pcli/src/command/tx/proposal.rs @@ -3,7 +3,7 @@ use anyhow::{Context, Result}; use penumbra_app::params::AppParameters; use penumbra_governance::{proposal::ChangedAppParameters, Proposal, ProposalPayload}; use penumbra_proto::DomainType; -use penumbra_transaction::plan::TransactionPlan; +use penumbra_transaction::TransactionPlan; use super::FeeTier; diff --git a/crates/bin/pcli/src/network.rs b/crates/bin/pcli/src/network.rs index a41cda945c..553f3443ff 100644 --- a/crates/bin/pcli/src/network.rs +++ b/crates/bin/pcli/src/network.rs @@ -6,9 +6,7 @@ use penumbra_proto::{ view::v1::broadcast_transaction_response::Status as BroadcastStatus, view::v1::GasPricesRequest, DomainType, }; -use penumbra_transaction::{ - gas::GasCost, plan::TransactionPlan, txhash::TransactionId, Transaction, -}; +use penumbra_transaction::{gas::GasCost, txhash::TransactionId, Transaction, TransactionPlan}; use penumbra_view::ViewClient; use std::future::Future; use tonic::transport::{Channel, ClientTlsConfig}; diff --git a/crates/bin/pcli/src/terminal.rs b/crates/bin/pcli/src/terminal.rs index 39e59bfcb9..5238380b44 100644 --- a/crates/bin/pcli/src/terminal.rs +++ b/crates/bin/pcli/src/terminal.rs @@ -1,6 +1,6 @@ use anyhow::Result; use penumbra_custody::threshold::Terminal; -use penumbra_transaction::plan::TransactionPlan; +use penumbra_transaction::TransactionPlan; use tokio::io::{self, AsyncBufReadExt}; use tonic::async_trait; diff --git a/crates/bin/pclientd/tests/network_integration.rs b/crates/bin/pclientd/tests/network_integration.rs index 20a77ef45b..7f02c207ce 100644 --- a/crates/bin/pclientd/tests/network_integration.rs +++ b/crates/bin/pclientd/tests/network_integration.rs @@ -314,13 +314,12 @@ async fn swap_claim_flow() -> anyhow::Result<()> { .ok_or_else(|| anyhow::anyhow!("TransactionPlannerResponse missing plan"))?; // Hold on to the swap plaintext to be able to claim. - let swap_plaintext = - TryInto::::try_into(plan.clone())? - .swap_plans() - .next() - .expect("swap plan must be present") - .swap_plaintext - .clone(); + let swap_plaintext = TryInto::::try_into(plan.clone())? + .swap_plans() + .next() + .expect("swap plan must be present") + .swap_plaintext + .clone(); // 5.2. Get authorization data for the transaction from pclientd (signing). let auth_data = custody_client diff --git a/crates/core/app/src/action_handler/actions/submit.rs b/crates/core/app/src/action_handler/actions/submit.rs index 58a60bc30c..0fb900b1b9 100644 --- a/crates/core/app/src/action_handler/actions/submit.rs +++ b/crates/core/app/src/action_handler/actions/submit.rs @@ -25,9 +25,7 @@ use penumbra_proto::{DomainType, StateWriteProto as _}; use penumbra_sct::component::clock::EpochRead; use penumbra_sct::component::tree::SctRead; use penumbra_shielded_pool::component::SupplyWrite; -use penumbra_transaction::plan::TransactionPlan; -use penumbra_transaction::Transaction; -use penumbra_transaction::{AuthorizationData, WitnessData}; +use penumbra_transaction::{AuthorizationData, Transaction, TransactionPlan, WitnessData}; use crate::action_handler::ActionHandler; use crate::community_pool_ext::CommunityPoolStateWriteExt; diff --git a/crates/core/transaction/src/lib.rs b/crates/core/transaction/src/lib.rs index a5d244a15d..9925d59132 100644 --- a/crates/core/transaction/src/lib.rs +++ b/crates/core/transaction/src/lib.rs @@ -3,7 +3,7 @@ //! This crate defines data structures that provide modeling of shielded //! transactions through their entire lifecycle: //! -//! * the [`TransactionPlan`](plan::TransactionPlan) type completely describes a +//! * the [`TransactionPlan`](TransactionPlan) type completely describes a //! planned transaction before it is created; //! //! * the [`Transaction`] type represents the shielded transaction itself; @@ -37,7 +37,7 @@ pub use detection_data::DetectionData; pub use error::Error; pub use is_action::IsAction; pub use parameters::TransactionParameters; -pub use plan::ActionPlan; +pub use plan::{ActionPlan, TransactionPlan}; pub use transaction::{Transaction, TransactionBody}; pub use view::{ActionView, MemoPlaintextView, MemoView, TransactionPerspective, TransactionView}; pub use witness_data::WitnessData; diff --git a/crates/core/transaction/src/plan/auth.rs b/crates/core/transaction/src/plan/auth.rs index 2b22fbdfb5..bd32bc0ced 100644 --- a/crates/core/transaction/src/plan/auth.rs +++ b/crates/core/transaction/src/plan/auth.rs @@ -3,7 +3,7 @@ use rand::{CryptoRng, RngCore}; use penumbra_keys::keys::SpendKey; -use crate::{plan::TransactionPlan, AuthorizationData}; +use crate::{AuthorizationData, TransactionPlan}; impl TransactionPlan { /// Authorize this [`TransactionPlan`] with the provided [`SpendKey`]. diff --git a/crates/custody/src/policy.rs b/crates/custody/src/policy.rs index b015aa0cab..629f33cdc1 100644 --- a/crates/custody/src/policy.rs +++ b/crates/custody/src/policy.rs @@ -34,7 +34,7 @@ pub enum AuthPolicy { /// This policy should be combined with an `AllowList` to prevent sending /// funds outside of the relayer account. OnlyIbcRelay, - /// Require specific pre-authorizations for submitted [`TransactionPlan`](penumbra_transaction::plan::TransactionPlan)s. + /// Require specific pre-authorizations for submitted [`TransactionPlan`](penumbra_transaction::TransactionPlan)s. PreAuthorization(PreAuthorizationPolicy), } diff --git a/crates/custody/src/pre_auth.rs b/crates/custody/src/pre_auth.rs index e686dcc6a1..d170832305 100644 --- a/crates/custody/src/pre_auth.rs +++ b/crates/custody/src/pre_auth.rs @@ -1,5 +1,5 @@ use penumbra_proto::{custody::v1 as pb, DomainType}; -use penumbra_transaction::plan::TransactionPlan; +use penumbra_transaction::TransactionPlan; use serde::{Deserialize, Serialize}; /// A pre-authorization packet. This allows a custodian to delegate (partial) diff --git a/crates/custody/src/request.rs b/crates/custody/src/request.rs index a4df230268..bc0d26e3ac 100644 --- a/crates/custody/src/request.rs +++ b/crates/custody/src/request.rs @@ -1,5 +1,5 @@ use penumbra_proto::{custody::v1 as pb, DomainType}; -use penumbra_transaction::plan::TransactionPlan; +use penumbra_transaction::TransactionPlan; use crate::PreAuthorization; diff --git a/crates/custody/src/soft_kms.rs b/crates/custody/src/soft_kms.rs index 5c3faf85dc..938ee027a4 100644 --- a/crates/custody/src/soft_kms.rs +++ b/crates/custody/src/soft_kms.rs @@ -24,7 +24,7 @@ impl SoftKms { Self { config } } - /// Attempt to authorize the requested [`TransactionPlan`](penumbra_transaction::plan::TransactionPlan). + /// Attempt to authorize the requested [`TransactionPlan`](penumbra_transaction::TransactionPlan). #[tracing::instrument(skip(self, request), name = "softhsm_sign")] pub fn sign(&self, request: &AuthorizeRequest) -> anyhow::Result { tracing::debug!(?request.plan); diff --git a/crates/custody/src/threshold.rs b/crates/custody/src/threshold.rs index 96cf1cd40f..28c58d70a6 100644 --- a/crates/custody/src/threshold.rs +++ b/crates/custody/src/threshold.rs @@ -5,7 +5,7 @@ use tonic::{async_trait, Request, Response, Status}; use penumbra_keys::{keys::AddressIndex, Address, FullViewingKey}; use penumbra_proto::{custody::v1 as pb, DomainType}; -use penumbra_transaction::{plan::TransactionPlan, AuthorizationData}; +use penumbra_transaction::{AuthorizationData, TransactionPlan}; use crate::AuthorizeRequest; diff --git a/crates/custody/src/threshold/sign.rs b/crates/custody/src/threshold/sign.rs index a5ccd793a1..60c21e1648 100644 --- a/crates/custody/src/threshold/sign.rs +++ b/crates/custody/src/threshold/sign.rs @@ -10,7 +10,7 @@ use rand_core::CryptoRngCore; use decaf377_frost as frost; use frost::round1::SigningCommitments; use penumbra_proto::{penumbra::custody::threshold::v1 as pb, DomainType, Message}; -use penumbra_transaction::{plan::TransactionPlan, AuthorizationData}; +use penumbra_transaction::{AuthorizationData, TransactionPlan}; use penumbra_txhash::EffectHash; use super::config::Config; diff --git a/crates/view/src/client.rs b/crates/view/src/client.rs index 9045ad0c0d..f87d1b4835 100644 --- a/crates/view/src/client.rs +++ b/crates/view/src/client.rs @@ -21,9 +21,8 @@ use penumbra_proto::view::v1::{ use penumbra_sct::Nullifier; use penumbra_shielded_pool::{fmd, note}; use penumbra_stake::IdentityKey; -use penumbra_transaction::AuthorizationData; use penumbra_transaction::{ - plan::TransactionPlan, txhash::TransactionId, Transaction, WitnessData, + txhash::TransactionId, AuthorizationData, Transaction, TransactionPlan, WitnessData, }; use crate::{SpendableNoteRecord, StatusStreamResponse, SwapRecord, TransactionInfo}; diff --git a/crates/view/src/service.rs b/crates/view/src/service.rs index 61dfdc30b9..285f255c59 100644 --- a/crates/view/src/service.rs +++ b/crates/view/src/service.rs @@ -55,7 +55,7 @@ use penumbra_proto::{ use penumbra_stake::rate::RateData; use penumbra_tct::{Proof, StateCommitment}; use penumbra_transaction::{ - plan::TransactionPlan, AuthorizationData, Transaction, TransactionPerspective, WitnessData, + AuthorizationData, Transaction, TransactionPerspective, TransactionPlan, WitnessData, }; use crate::{Planner, Storage, Worker}; diff --git a/crates/wallet/src/build.rs b/crates/wallet/src/build.rs index b9772067af..24577816d7 100644 --- a/crates/wallet/src/build.rs +++ b/crates/wallet/src/build.rs @@ -2,7 +2,7 @@ use anyhow::Result; use penumbra_custody::{AuthorizeRequest, CustodyClient}; use penumbra_keys::FullViewingKey; -use penumbra_transaction::{plan::TransactionPlan, AuthorizationData, Transaction}; +use penumbra_transaction::{AuthorizationData, Transaction, TransactionPlan}; use penumbra_view::ViewClient; pub async fn build_transaction( diff --git a/crates/wallet/src/plan.rs b/crates/wallet/src/plan.rs index 25716aeb1d..b41041003a 100644 --- a/crates/wallet/src/plan.rs +++ b/crates/wallet/src/plan.rs @@ -15,7 +15,7 @@ use penumbra_num::Amount; use penumbra_proto::view::v1::NotesRequest; use penumbra_stake::rate::RateData; use penumbra_stake::validator; -use penumbra_transaction::{memo::MemoPlaintext, plan::TransactionPlan, TransactionParameters}; +use penumbra_transaction::{memo::MemoPlaintext, TransactionParameters, TransactionPlan}; pub use penumbra_view::Planner; use penumbra_view::{SpendableNoteRecord, ViewClient};