-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
169 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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
mod delegated_feeder; | ||
mod index_wrapper; | ||
mod restrictions; | ||
mod vault_1_of_n; | ||
mod vault_m_of_n; | ||
mod vault_n_of_n; | ||
|
||
pub use delegated_feeder::*; | ||
pub use index_wrapper::*; | ||
pub use restrictions::*; | ||
pub use vault_1_of_n::*; | ||
pub use vault_m_of_n::*; | ||
pub use vault_n_of_n::*; |
57 changes: 57 additions & 0 deletions
57
crates/chia-sdk-types/src/puzzles/vault/delegated_feeder.rs
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,57 @@ | ||
use clvm_traits::{FromClvm, ToClvm}; | ||
use clvm_utils::TreeHash; | ||
use hex_literal::hex; | ||
|
||
use crate::Mod; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq, ToClvm, FromClvm)] | ||
#[clvm(curry)] | ||
pub struct DelegatedFeederArgs<I> { | ||
pub inner_puzzle: I, | ||
} | ||
|
||
impl<I> DelegatedFeederArgs<I> { | ||
pub fn new(inner_puzzle: I) -> Self { | ||
Self { inner_puzzle } | ||
} | ||
} | ||
|
||
impl<I> Mod for DelegatedFeederArgs<I> { | ||
const MOD_REVEAL: &[u8] = &DELEGATED_FEEDER_PUZZLE; | ||
const MOD_HASH: TreeHash = DELEGATED_FEEDER_PUZZLE_HASH; | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, ToClvm, FromClvm)] | ||
#[clvm(solution)] | ||
pub struct DelegatedFeederSolution<P, S, I> { | ||
pub delegated_puzzle: P, | ||
pub delegated_solution: S, | ||
#[clvm(rest)] | ||
pub inner_solution: I, | ||
} | ||
|
||
impl<P, S, I> DelegatedFeederSolution<P, S, I> { | ||
pub fn new(delegated_puzzle: P, delegated_solution: S, inner_solution: I) -> Self { | ||
Self { | ||
delegated_puzzle, | ||
delegated_solution, | ||
inner_solution, | ||
} | ||
} | ||
} | ||
|
||
pub const DELEGATED_FEEDER_PUZZLE: [u8; 203] = hex!( | ||
" | ||
ff02ffff01ff02ff04ffff04ff02ffff04ffff02ff05ffff04ffff02ff06ffff | ||
04ff02ffff04ff0bff80808080ff1f8080ffff04ffff02ff0bff1780ff808080 | ||
8080ffff04ffff01ffff02ffff03ff05ffff01ff04ff09ffff02ff04ffff04ff | ||
02ffff04ff0dffff04ff0bff808080808080ffff010b80ff0180ff02ffff03ff | ||
ff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff8080 | ||
8080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101 | ||
ff058080ff0180ff018080 | ||
" | ||
); | ||
|
||
pub const DELEGATED_FEEDER_PUZZLE_HASH: TreeHash = TreeHash::new(hex!( | ||
"9db33d93853179903d4dd272a00345ee6630dc94907dbcdd96368df6931060fd" | ||
)); |
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,32 @@ | ||
use clvm_traits::{FromClvm, ToClvm}; | ||
use clvm_utils::TreeHash; | ||
use hex_literal::hex; | ||
|
||
use crate::Mod; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq, ToClvm, FromClvm)] | ||
#[clvm(curry)] | ||
pub struct IndexWrapperArgs<I> { | ||
pub index: u32, | ||
pub inner_puzzle: I, | ||
} | ||
|
||
impl<I> IndexWrapperArgs<I> { | ||
pub fn new(index: u32, inner_puzzle: I) -> Self { | ||
Self { | ||
index, | ||
inner_puzzle, | ||
} | ||
} | ||
} | ||
|
||
impl<I> Mod for IndexWrapperArgs<I> { | ||
const MOD_REVEAL: &[u8] = &INDEX_WRAPPER; | ||
const MOD_HASH: TreeHash = INDEX_WRAPPER_HASH; | ||
} | ||
|
||
pub const INDEX_WRAPPER: [u8; 7] = hex!("ff02ff05ff0780"); | ||
|
||
pub const INDEX_WRAPPER_HASH: TreeHash = TreeHash::new(hex!( | ||
"847d971ef523417d555ea9854b1612837155d34d453298defcd310774305f657" | ||
)); |
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,74 @@ | ||
use chia_protocol::Bytes32; | ||
use clvm_traits::{FromClvm, ToClvm}; | ||
use clvm_utils::TreeHash; | ||
use hex_literal::hex; | ||
|
||
use crate::Mod; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, ToClvm, FromClvm)] | ||
#[clvm(curry)] | ||
pub struct RestrictionsArgs<MV, DV, I> { | ||
pub member_validators: Vec<MV>, | ||
pub delegated_puzzle_validators: Vec<DV>, | ||
pub inner_puzzle: I, | ||
} | ||
|
||
impl<MV, DV, I> RestrictionsArgs<MV, DV, I> { | ||
pub fn new( | ||
member_validators: Vec<MV>, | ||
delegated_puzzle_validators: Vec<DV>, | ||
inner_puzzle: I, | ||
) -> Self { | ||
Self { | ||
member_validators, | ||
delegated_puzzle_validators, | ||
inner_puzzle, | ||
} | ||
} | ||
} | ||
|
||
impl<MV, DV, I> Mod for RestrictionsArgs<MV, DV, I> { | ||
const MOD_REVEAL: &[u8] = &RESTRICTIONS_PUZZLE; | ||
const MOD_HASH: TreeHash = RESTRICTIONS_PUZZLE_HASH; | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, ToClvm, FromClvm)] | ||
#[clvm(solution)] | ||
pub struct RestrictionsSolution<MV, DV, I> { | ||
pub delegated_puzzle_hash: Bytes32, | ||
pub member_validator_solutions: Vec<MV>, | ||
pub delegated_puzzle_validator_solutions: Vec<DV>, | ||
pub inner_solution: I, | ||
} | ||
|
||
impl<MV, DV, I> RestrictionsSolution<MV, DV, I> { | ||
pub fn new( | ||
delegated_puzzle_hash: Bytes32, | ||
member_validator_solutions: Vec<MV>, | ||
delegated_puzzle_validator_solutions: Vec<DV>, | ||
inner_solution: I, | ||
) -> Self { | ||
Self { | ||
delegated_puzzle_hash, | ||
member_validator_solutions, | ||
delegated_puzzle_validator_solutions, | ||
inner_solution, | ||
} | ||
} | ||
} | ||
|
||
pub const RESTRICTIONS_PUZZLE: [u8; 204] = hex!( | ||
" | ||
ff02ffff01ff02ff04ffff04ff02ffff04ff05ffff04ff5fffff04ffff02ff17 | ||
ffff04ff2fff82017f8080ffff04ffff02ff06ffff04ff02ffff04ff0bffff04 | ||
ff81bfffff04ff2fff808080808080ff80808080808080ffff04ffff01ffff03 | ||
ff80ffff02ff06ffff04ff02ffff04ff05ffff04ff0bffff04ff17ff80808080 | ||
8080ff1780ff02ffff03ff05ffff01ff03ff80ffff02ff09ffff04ff17ff1380 | ||
80ffff02ff06ffff04ff02ffff04ff0dffff04ff1bffff04ff17ff8080808080 | ||
8080ff8080ff0180ff018080 | ||
" | ||
); | ||
|
||
pub const RESTRICTIONS_PUZZLE_HASH: TreeHash = TreeHash::new(hex!( | ||
"a28d59d39f964a93159c986b1914694f6f2f1c9901178f91e8b0ba4045980eef" | ||
)); |