-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit: - Aligns the `TransactionPlan` with the `Transaction` data structure - Moves the `fee` into the `TransactionParameters` Now the transaction body consists solely of: - a list of `Action`s describing changes to the chain state - a set of `TransactionParameters` describing under what conditions those changes can be applied - a set of `DetectionData` (extensible) for assisting with transaction detection - a set of `MemoData` with encrypted information about the transaction's purpose.
- Loading branch information
1 parent
1eb74b7
commit a3f76dc
Showing
48 changed files
with
1,579 additions
and
1,456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use anyhow::Error; | ||
use decaf377_fmd::Clue; | ||
use penumbra_proto::core::transaction::v1alpha1 as pbt; | ||
use penumbra_proto::DomainType; | ||
|
||
/// Detection data used by a detection server using Fuzzy Message Detection. | ||
/// | ||
/// Only present if outputs are present. | ||
#[derive(Clone, Debug, Default)] | ||
pub struct DetectionData { | ||
pub fmd_clues: Vec<Clue>, | ||
} | ||
|
||
impl DomainType for DetectionData { | ||
type Proto = pbt::DetectionData; | ||
} | ||
|
||
impl TryFrom<pbt::DetectionData> for DetectionData { | ||
type Error = Error; | ||
|
||
fn try_from(proto: pbt::DetectionData) -> anyhow::Result<Self, Self::Error> { | ||
let fmd_clues = proto | ||
.fmd_clues | ||
.into_iter() | ||
.map(|x| x.try_into()) | ||
.collect::<Result<Vec<Clue>, Error>>()?; | ||
Ok(DetectionData { fmd_clues }) | ||
} | ||
} | ||
|
||
impl From<DetectionData> for pbt::DetectionData { | ||
fn from(msg: DetectionData) -> Self { | ||
let fmd_clues = msg.fmd_clues.into_iter().map(|x| x.into()).collect(); | ||
|
||
pbt::DetectionData { fmd_clues } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use anyhow::Error; | ||
use penumbra_fee::Fee; | ||
use penumbra_proto::core::transaction::v1alpha1 as pbt; | ||
use penumbra_proto::DomainType; | ||
|
||
/// Parameters determining when the transaction should be accepted to the chain. | ||
#[derive(Clone, Debug, Default)] | ||
pub struct TransactionParameters { | ||
pub expiry_height: u64, | ||
pub chain_id: String, | ||
pub fee: Fee, | ||
} | ||
|
||
impl DomainType for TransactionParameters { | ||
type Proto = pbt::TransactionParameters; | ||
} | ||
|
||
impl TryFrom<pbt::TransactionParameters> for TransactionParameters { | ||
type Error = Error; | ||
|
||
fn try_from(proto: pbt::TransactionParameters) -> anyhow::Result<Self, Self::Error> { | ||
Ok(TransactionParameters { | ||
expiry_height: proto.expiry_height, | ||
chain_id: proto.chain_id, | ||
fee: proto | ||
.fee | ||
.ok_or_else(|| anyhow::anyhow!("transaction parameters missing fee"))? | ||
.try_into()?, | ||
}) | ||
} | ||
} | ||
|
||
impl From<TransactionParameters> for pbt::TransactionParameters { | ||
fn from(msg: TransactionParameters) -> Self { | ||
pbt::TransactionParameters { | ||
expiry_height: msg.expiry_height, | ||
chain_id: msg.chain_id, | ||
fee: Some(msg.fee.into()), | ||
} | ||
} | ||
} |
Oops, something went wrong.