-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
marketplace solver rollup registration types (#1802)
- adds rollup registration and rollup update types - implements commitable trait for these types
- Loading branch information
Showing
4 changed files
with
123 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ mod fee_info; | |
mod header; | ||
mod instance_state; | ||
mod l1; | ||
mod solver; | ||
mod state; | ||
mod transaction; | ||
|
||
|
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,67 @@ | ||
use committable::{Commitment, Committable}; | ||
use hotshot::types::SignatureKey; | ||
|
||
use super::v0_3::{RollupRegistrationBody, RollupUpdatebody}; | ||
|
||
impl Committable for RollupRegistrationBody { | ||
fn tag() -> String { | ||
"ROLLUP_REGISTRATION".to_string() | ||
} | ||
|
||
fn commit(&self) -> Commitment<Self> { | ||
let mut comm = committable::RawCommitmentBuilder::new(&Self::tag()) | ||
.u64_field("namespace_id", u64::from(self.namespace_id)) | ||
.var_size_field("reserve_url", self.reserve_url.as_str().as_ref()) | ||
.fixed_size_field("reserve_price", &self.reserve_price.to_fixed_bytes()) | ||
.fixed_size_field("active", &[u8::from(self.active)]) | ||
.constant_str("signature_keys"); | ||
|
||
for key in self.signature_keys.iter() { | ||
comm = comm.var_size_bytes(&key.to_bytes()); | ||
} | ||
|
||
comm = comm | ||
.var_size_field("signature_key", &self.signature_key.to_bytes()) | ||
.var_size_field("text", self.text.as_bytes()); | ||
|
||
comm.finalize() | ||
} | ||
} | ||
|
||
impl Committable for RollupUpdatebody { | ||
fn tag() -> String { | ||
"ROLLUP_UPDATE".to_string() | ||
} | ||
|
||
fn commit(&self) -> Commitment<Self> { | ||
let mut comm = committable::RawCommitmentBuilder::new(&Self::tag()) | ||
.u64_field("namespace_id", u64::from(self.namespace_id)); | ||
|
||
if let Some(reserve_url) = &self.reserve_url { | ||
comm = comm.var_size_field("reserve_url", reserve_url.as_str().as_ref()) | ||
} | ||
|
||
if let Some(rp) = self.reserve_price { | ||
comm = comm.fixed_size_field("reserve_price", &rp.to_fixed_bytes()) | ||
}; | ||
|
||
if let Some(active) = self.active { | ||
comm = comm.fixed_size_field("active", &[u8::from(active)]); | ||
} | ||
|
||
if let Some(keys) = &self.signature_keys { | ||
comm = comm.constant_str("signature_keys"); | ||
for key in keys.iter() { | ||
comm = comm.var_size_bytes(&key.to_bytes()); | ||
} | ||
} | ||
|
||
comm = comm.var_size_field("signature_key", &self.signature_key.to_bytes()); | ||
|
||
if let Some(text) = &self.text { | ||
comm = comm.var_size_field("text", text.as_bytes()); | ||
} | ||
|
||
comm.finalize() | ||
} | ||
} |
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,53 @@ | ||
use crate::{FeeAmount, NamespaceId, SeqTypes}; | ||
use hotshot::types::SignatureKey; | ||
use hotshot_types::traits::node_implementation::NodeType; | ||
use serde::{Deserialize, Serialize}; | ||
use tide_disco::Url; | ||
|
||
#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)] | ||
pub struct RollupRegistration { | ||
pub body: RollupRegistrationBody, | ||
// signature over the above data (must be from a key in the 'signature_keys` list) | ||
pub signature: | ||
<<SeqTypes as NodeType>::SignatureKey as SignatureKey>::PureAssembledSignatureType, | ||
} | ||
|
||
#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)] | ||
pub struct RollupRegistrationBody { | ||
pub namespace_id: NamespaceId, | ||
pub reserve_url: Url, | ||
// Denominated in Wei | ||
pub reserve_price: FeeAmount, | ||
// whether this registration is active in the marketplace | ||
pub active: bool, | ||
// a list of keys authorized to update the registration information | ||
pub signature_keys: Vec<<SeqTypes as NodeType>::SignatureKey>, | ||
// The signature key used to sign this registration body | ||
pub signature_key: <SeqTypes as NodeType>::SignatureKey, | ||
// Optional field for human readable information | ||
pub text: String, | ||
} | ||
|
||
#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)] | ||
pub struct RollupUpdate { | ||
pub body: RollupUpdatebody, | ||
// signature over the above data (must be from a key in the 'signature_keys` list) | ||
pub signature: | ||
<<SeqTypes as NodeType>::SignatureKey as SignatureKey>::PureAssembledSignatureType, | ||
} | ||
|
||
#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)] | ||
pub struct RollupUpdatebody { | ||
pub namespace_id: NamespaceId, | ||
// Denominated in Wei | ||
pub reserve_url: Option<Url>, | ||
pub reserve_price: Option<FeeAmount>, | ||
// whether this registration is active in the marketplace | ||
pub active: Option<bool>, | ||
// a list of keys authorized to update the registration information | ||
pub signature_keys: Option<Vec<<SeqTypes as NodeType>::SignatureKey>>, | ||
// The signature key used to sign this update body | ||
pub signature_key: <SeqTypes as NodeType>::SignatureKey, | ||
// Optional field for human readable information | ||
pub text: Option<String>, | ||
} |