Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lift HasSampleValues restriction on Signable trait #290

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/sargon/src/signing/host_interaction/sign_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ impl<S: Signable> SignRequest<S> {
}
}

impl<S: Signable> HasSampleValues for SignRequest<S> {
impl<S: Signable + HasSampleValues> HasSampleValues for SignRequest<S>
where
S::Payload: HasSampleValues,
S::ID: HasSampleValues,
{
fn sample() -> Self {
Self::new(
FactorSourceKind::sample(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<ID: SignableID> SignResponse<ID> {
}
}

impl<ID: SignableID> HasSampleValues for SignResponse<ID> {
impl<ID: SignableID + HasSampleValues> HasSampleValues for SignResponse<ID> {
fn sample() -> Self {
let hd_signature = HDSignature::sample();
let factor_source_id = hd_signature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ impl<S: Signable> TransactionSignRequestInput<S> {
}
}

impl<S: Signable> HasSampleValues for TransactionSignRequestInput<S> {
impl<S: Signable + HasSampleValues> HasSampleValues
for TransactionSignRequestInput<S>
where
S::Payload: HasSampleValues,
{
fn sample() -> Self {
let owned_factor_instance = OwnedFactorInstance::sample();
let factor_source_id = &owned_factor_instance.factor_source_id();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ impl<ID: SignableID> PetitionForEntity<ID> {
}
}

impl<ID: SignableID> HasSampleValues for PetitionForEntity<ID> {
impl<ID: SignableID + HasSampleValues> HasSampleValues
for PetitionForEntity<ID>
{
fn sample() -> Self {
Self::from_entity_with_role_kind(
Account::sample_securified_mainnet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ impl<ID: SignableID> PetitionForFactorsStateSnapshot<ID> {
}
}

impl<ID: SignableID> HasSampleValues for PetitionForFactorsStateSnapshot<ID> {
impl<ID: SignableID + HasSampleValues> HasSampleValues
for PetitionForFactorsStateSnapshot<ID>
{
fn sample() -> Self {
Self::new(
IndexSet::from_iter([
Expand Down
5 changes: 2 additions & 3 deletions crates/sargon/src/signing/signables/signable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::hash::Hasher;
/// Any type conforming to `Signable` can be used with `SignaturesCollector` and collect
/// signatures from all involved entities according to their security structure.
pub trait Signable:
std::hash::Hash + PartialEq + Eq + Clone + Debug + HasSampleValues + Send + Sync
std::hash::Hash + PartialEq + Eq + Clone + Debug + Send + Sync
{
/// A stable identifier for this `Signable`.
type ID: SignableID;
Expand All @@ -17,7 +17,6 @@ pub trait Signable:
+ std::hash::Hash
+ Into<Self::ID>
+ From<Self>
+ HasSampleValues
+ Send
+ Sync;

Expand Down Expand Up @@ -128,6 +127,6 @@ pub trait Signable:

/// An identifier that is unique for each `Signable`
pub trait SignableID:
Eq + StdHash + Clone + Debug + Into<Hash> + HasSampleValues + Send + Sync
Eq + StdHash + Clone + Debug + Into<Hash> + Send + Sync
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ impl<ID: SignableID> MaybeSignedTransactions<ID> {
}
}

impl<ID: SignableID> HasSampleValues for MaybeSignedTransactions<ID> {
impl<ID: SignableID + HasSampleValues> HasSampleValues
for MaybeSignedTransactions<ID>
{
fn sample() -> Self {
let tx_a = ID::sample();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ pub enum SignWithFactorsOutcome<ID: SignableID> {
Neglected(NeglectedFactors),
}

impl<ID: SignableID> HasSampleValues for SignWithFactorsOutcome<ID> {
impl<ID: SignableID + HasSampleValues> HasSampleValues
for SignWithFactorsOutcome<ID>
{
fn sample() -> Self {
Self::signed(SignResponse::sample())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sargon/src/types/hd_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<ID: SignableID> HDSignature<ID> {
}
}

impl<ID: SignableID> HasSampleValues for HDSignature<ID> {
impl<ID: SignableID + HasSampleValues> HasSampleValues for HDSignature<ID> {
fn sample() -> Self {
Self::fake_sign_by_looking_up_mnemonic_amongst_samples(
HDSignatureInput::<ID>::sample(),
Expand Down
4 changes: 3 additions & 1 deletion crates/sargon/src/types/hd_signature_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ impl<ID: SignableID> HDSignatureInput<ID> {
}
}

impl<ID: SignableID> HasSampleValues for HDSignatureInput<ID> {
impl<ID: SignableID + HasSampleValues> HasSampleValues
for HDSignatureInput<ID>
{
fn sample() -> Self {
Self::new(ID::sample(), OwnedFactorInstance::sample())
}
Expand Down
4 changes: 3 additions & 1 deletion crates/sargon/src/types/invalid_transaction_if_neglected.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ impl<ID: SignableID> InvalidTransactionIfNeglected<ID> {
}
}

impl<ID: SignableID> HasSampleValues for InvalidTransactionIfNeglected<ID> {
impl<ID: SignableID + HasSampleValues> HasSampleValues
for InvalidTransactionIfNeglected<ID>
{
fn sample() -> Self {
Self::new(ID::sample(), vec![AddressOfAccountOrPersona::sample()])
}
Expand Down
Loading