-
Notifications
You must be signed in to change notification settings - Fork 1
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
4 zome re structure and crate docs #89
base: main
Are you sure you want to change the base?
Changes from all commits
7017b66
1d50aa8
2c42fd5
f7518c0
a249377
69849b0
f76b533
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,42 +6,74 @@ opt-level = "z" | |
|
||
[workspace] | ||
resolver = "2" | ||
members = ["crates/*"] | ||
members = ["crates/*/coordinator","crates/*/integrity"] | ||
|
||
[workspace.dependencies] | ||
hdi = "=0.5.0-dev.9" | ||
hdk = "=0.4.0-dev.10" | ||
holo_hash = { version = "=0.4.0-dev.8", features = ["encoding"] } | ||
hdi = "=0.5.0-dev.10" | ||
hdk = "=0.4.0-dev.12" | ||
holo_hash = { version = "=0.4.0-dev.9", features = ["encoding"] } | ||
serde = "1" | ||
serde_json = "1" | ||
bincode = "1.3.3" | ||
hex = "0.4.3" | ||
alloy-primitives = { version = "0.6.3", features = ["serde", "k256"] } | ||
ed25519-dalek = { version = "2.1.1", features = ["serde"] } | ||
bs58 = "0.5.0" | ||
bs58 = "0.5" | ||
ethers-signers = "0.6.2" | ||
holochain = { version = "=0.4.0-dev.12", default-features = false, features = [ | ||
holochain = { version = "=0.4.0-dev.16", default-features = false, features = [ | ||
"test_utils", | ||
] } | ||
holochain_keystore = "=0.4.0-dev.12" | ||
holochain_keystore = "=0.4.0-dev.15" | ||
#holochain_integrity_types = "0.3" | ||
|
||
[workspace.dependencies.holoom_types] | ||
path = "crates/holoom_types" | ||
|
||
[workspace.dependencies.jaq_wrapper] | ||
path = "crates/jaq_wrapper" | ||
|
||
[workspace.dependencies.username_registry_utils] | ||
path = "crates/username_registry_utils" | ||
[workspace.dependencies.shared_utils] | ||
path = "crates/shared_utils" | ||
|
||
[workspace.dependencies.username_registry_validation] | ||
path = "crates/username_registry_validation" | ||
[workspace.dependencies.evm_attestation_coordinator] | ||
path = "crates/evm_attestation/coordinator" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok i used the term for a package name to refer to all EVM operations that would imply some kind of attestation.. we can change the package name |
||
|
||
[workspace.dependencies.username_registry_integrity] | ||
path = "crates/username_registry_integrity" | ||
[workspace.dependencies.evm_attestation_integrity] | ||
path = "crates/evm_attestation/integrity" | ||
|
||
[workspace.dependencies.username_registry_coordinator] | ||
path = "crates/username_registry_coordinator" | ||
[workspace.dependencies.username_attestation_coordinator] | ||
path = "crates/username_attestation/coordinator" | ||
|
||
[workspace.dependencies.username_attestation_integrity] | ||
path = "crates/username_attestation/integrity" | ||
|
||
[workspace.dependencies.external_attestation] | ||
path = "crates/external_attestation/coordinator" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confusing name. The crate is specifically for attesting external IDs. The attestation isn't itself external. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shortened the name as .. i thought it obvious that the attestation would be on an ID |
||
|
||
[workspace.dependencies.external_attestation_integrity] | ||
path = "crates/external_attestation/integrity" | ||
|
||
[workspace.dependencies.wallet_attestation] | ||
path = "crates/wallet_attestation/coordinator" | ||
|
||
[workspace.dependencies.wallet_attestation_integrity] | ||
path = "crates/wallet_attestation/integrity" | ||
|
||
[workspace.dependencies.oracle_document] | ||
path = "crates/oracle_document/coordinator" | ||
|
||
[workspace.dependencies.oracle_document_integrity] | ||
path = "crates/oracle_document/integrity" | ||
|
||
[workspace.dependencies.holoom_recipe] | ||
path = "crates/holoom_recipe/coordinator" | ||
|
||
[workspace.dependencies.holoom_recipe_integrity] | ||
path = "crates/holoom_recipe/integrity" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any particular reason for adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For me They are meta operations .. you could create recipes for anything... but here we are creating recipes specifically for holoom crates/packages |
||
|
||
[workspace.dependencies.holoom_recipe_execution] | ||
path = "crates/holoom_recipe_execution/coordinator" | ||
|
||
[workspace.dependencies.holoom_recipe_execution_integrity] | ||
path = "crates/holoom_recipe_execution/integrity" | ||
|
||
[workspace.dependencies.signer_coordinator] | ||
path = "crates/signer_coordinator" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "evm_attestation" | ||
version = "0.0.1" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
name = "evm_attestation" | ||
|
||
[dependencies] | ||
hdk = { workspace = true } | ||
serde = { workspace = true } | ||
holoom_types = { workspace = true } | ||
shared_utils = { workspace = true } | ||
evm_attestation_integrity = { workspace = true } | ||
jaq_wrapper = { workspace = true } | ||
|
||
#[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] #avoids mio bug | ||
#holochain = { workspace = true, default-features = false, features = ["test_utils"] } | ||
#tokio = "1.38.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
pub mod evm_signing_offer; | ||
use hdk::prelude::*; | ||
use holoom_types::{LocalHoloomSignal, RemoteHoloomSignal}; | ||
use shared_utils::get_authority_agent; | ||
|
||
#[hdk_extern] | ||
pub fn init(_: ()) -> ExternResult<InitCallbackResult> { | ||
let authority_agent = get_authority_agent()?; | ||
let my_pubkey = agent_info()?.agent_initial_pubkey; | ||
let mut functions = BTreeSet::new(); | ||
let zome_name = zome_info()?.name; | ||
if my_pubkey == authority_agent { | ||
functions.insert(( | ||
zome_name.clone(), "ingest_signed_username".into(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not relevant to this zome There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right that one might be a mistake.. |
||
)); | ||
} | ||
functions.insert((zome_name, "recv_remote_signal".into())); | ||
create_cap_grant(CapGrantEntry { | ||
tag: "".into(), | ||
access: ().into(), | ||
functions: GrantedFunctions::Listed(functions), | ||
})?; | ||
|
||
Ok(InitCallbackResult::Pass) | ||
} | ||
|
||
#[hdk_extern] | ||
fn recv_remote_signal(signal_io: ExternIO) -> ExternResult<()> { | ||
let remote_holoom_signal: RemoteHoloomSignal = signal_io | ||
.decode() | ||
.map_err(|e| wasm_error!(WasmErrorInner::Serialize(e)))?; | ||
|
||
match remote_holoom_signal { | ||
RemoteHoloomSignal::EvmSignatureProvided { | ||
request_id, | ||
signed_u256_array, | ||
} => emit_signal(LocalHoloomSignal::EvmSignatureProvided { | ||
request_id, | ||
signed_u256_array, | ||
})?, | ||
RemoteHoloomSignal::EvmSignatureRequestRejected { request_id, reason } => { | ||
emit_signal(LocalHoloomSignal::EvmSignatureRequestRejected { request_id, reason })? | ||
} | ||
_=>{} | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
#[hdk_extern] | ||
fn get_authority(_: ()) -> ExternResult<AgentPubKey> { | ||
get_authority_agent() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
[package] | ||
name = "username_registry_integrity" | ||
name = "evm_attestation_integrity" | ||
version = "0.0.1" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
name = "username_registry_integrity" | ||
name = "evm_attestation_integrity" | ||
|
||
[dependencies] | ||
hdi = { workspace = true } | ||
serde = { workspace = true } | ||
holoom_types = { workspace = true } | ||
username_registry_validation = { workspace = true } | ||
shared_utils = { workspace = true } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use hdi::prelude::*; | ||
use holoom_types::evm_signing_offer::SignedEvmSigningOffer; | ||
use crate::evm_signing_offer::*; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
#[serde(tag = "type")] | ||
#[hdk_entry_types] | ||
#[unit_enum(UnitEntryTypes)] | ||
pub enum EntryTypes { | ||
SignedEvmSigningOffer(SignedEvmSigningOffer), | ||
} | ||
|
||
impl EntryTypes { | ||
pub fn validate_create(self, action: Create) -> ExternResult<ValidateCallbackResult> { | ||
match self { | ||
EntryTypes::SignedEvmSigningOffer(evm_signing_offer) => { | ||
validate_create_signed_evm_signing_offer( | ||
EntryCreationAction::Create(action), | ||
evm_signing_offer, | ||
) | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
use hdi::prelude::*; | ||
pub mod entry_types; | ||
pub use entry_types::*; | ||
pub mod link_types; | ||
pub use link_types::*; | ||
pub mod evm_address_to_signing_offer; | ||
pub use evm_address_to_signing_offer::*; | ||
pub mod evm_signing_offer; | ||
pub use evm_signing_offer::*; | ||
pub mod name_to_evm_signing_offer; | ||
pub use name_to_evm_signing_offer::*; | ||
|
||
|
||
#[hdk_extern] | ||
pub fn genesis_self_check(_data: GenesisSelfCheckData) -> ExternResult<ValidateCallbackResult> { | ||
Ok(ValidateCallbackResult::Valid) | ||
} | ||
pub fn validate_agent_joining( | ||
_agent_pub_key: AgentPubKey, | ||
_membrane_proof: &Option<MembraneProof>, | ||
) -> ExternResult<ValidateCallbackResult> { | ||
Ok(ValidateCallbackResult::Valid) | ||
} | ||
#[hdk_extern] | ||
pub fn validate(op: Op) -> ExternResult<ValidateCallbackResult> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to find a way to generalise this since it's repeated so many times now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is another one we have to swallow.. as every zome has these common validation functions. trying to separate them from the zomes validation files.. wont work and breaks modularity. |
||
match op.flattened::<EntryTypes, LinkTypes>()? { | ||
FlatOp::StoreEntry(store_entry) => match store_entry { | ||
OpEntry::CreateEntry { app_entry, action } => app_entry.validate_create(action), | ||
OpEntry::UpdateEntry { .. } => Ok(ValidateCallbackResult::Invalid( | ||
"App EntryTypes cannot be updated".into(), | ||
)), | ||
_ => Ok(ValidateCallbackResult::Valid), | ||
}, | ||
FlatOp::RegisterUpdate(update_entry) => match update_entry { | ||
OpUpdate::Entry { .. } => Ok(ValidateCallbackResult::Invalid( | ||
"App EntryTypes cannot be updated".into(), | ||
)), | ||
_ => Ok(ValidateCallbackResult::Valid), | ||
}, | ||
FlatOp::RegisterDelete(_) => Ok(ValidateCallbackResult::Invalid( | ||
"App EntryTypes cannot be deleted".into(), | ||
)), | ||
FlatOp::RegisterCreateLink { | ||
link_type, | ||
base_address, | ||
target_address, | ||
tag, | ||
action, | ||
} => link_type.validate_create(action, base_address, target_address, tag), | ||
FlatOp::RegisterDeleteLink { | ||
link_type, | ||
base_address, | ||
target_address, | ||
tag, | ||
original_action, | ||
action, | ||
} => link_type.validate_delete(action, original_action, base_address, target_address, tag), | ||
FlatOp::StoreRecord(store_record) => { | ||
match store_record { | ||
OpRecord::CreateEntry { app_entry, action } => app_entry.validate_create(action), | ||
OpRecord::UpdateEntry { .. } => Ok(ValidateCallbackResult::Invalid( | ||
"App EntryTypes cannot be updated".into(), | ||
)), | ||
OpRecord::DeleteEntry { .. } => Ok(ValidateCallbackResult::Invalid( | ||
"App EntryTypes cannot be deleted".into(), | ||
)), | ||
OpRecord::CreateLink { | ||
base_address, | ||
target_address, | ||
tag, | ||
link_type, | ||
action, | ||
} => link_type.validate_create(action, base_address, target_address, tag), | ||
OpRecord::DeleteLink { | ||
original_action_hash, | ||
base_address, | ||
action, | ||
} => { | ||
let record = must_get_valid_record(original_action_hash)?; | ||
let create_link = match record.action() { | ||
Action::CreateLink(create_link) => create_link.clone(), | ||
_ => { | ||
return Ok(ValidateCallbackResult::Invalid( | ||
"The action that a DeleteLink deletes must be a CreateLink" | ||
.to_string(), | ||
)); | ||
} | ||
}; | ||
let link_type = match LinkTypes::from_type( | ||
create_link.zome_index, | ||
create_link.link_type, | ||
)? { | ||
Some(lt) => lt, | ||
None => { | ||
// @todo This must be treated as valid due to holochain bug | ||
// see https://github.com/holochain/holochain/issues/2868 | ||
return Ok(ValidateCallbackResult::Valid); | ||
} | ||
}; | ||
link_type.validate_delete( | ||
action, | ||
create_link.clone(), | ||
base_address, | ||
create_link.target_address, | ||
create_link.tag, | ||
) | ||
} | ||
OpRecord::CreatePrivateEntry { .. } => Ok(ValidateCallbackResult::Valid), | ||
OpRecord::UpdatePrivateEntry { .. } => Ok(ValidateCallbackResult::Valid), | ||
OpRecord::CreateCapClaim { .. } => Ok(ValidateCallbackResult::Valid), | ||
OpRecord::CreateCapGrant { .. } => Ok(ValidateCallbackResult::Valid), | ||
OpRecord::UpdateCapClaim { .. } => Ok(ValidateCallbackResult::Valid), | ||
OpRecord::UpdateCapGrant { .. } => Ok(ValidateCallbackResult::Valid), | ||
OpRecord::Dna { .. } => Ok(ValidateCallbackResult::Valid), | ||
OpRecord::OpenChain { .. } => Ok(ValidateCallbackResult::Valid), | ||
OpRecord::CloseChain { .. } => Ok(ValidateCallbackResult::Valid), | ||
OpRecord::InitZomesComplete { .. } => Ok(ValidateCallbackResult::Valid), | ||
_ => Ok(ValidateCallbackResult::Valid), | ||
} | ||
} | ||
FlatOp::RegisterAgentActivity(agent_activity) => match agent_activity { | ||
OpActivity::CreateAgent { agent, action } => { | ||
let previous_action = must_get_action(action.prev_action)?; | ||
match previous_action.action() { | ||
Action::AgentValidationPkg( | ||
AgentValidationPkg { membrane_proof, .. }, | ||
) => validate_agent_joining(agent, membrane_proof), | ||
_ => { | ||
Ok( | ||
ValidateCallbackResult::Invalid( | ||
"The previous action for a `CreateAgent` action must be an `AgentValidationPkg`" | ||
.to_string(), | ||
), | ||
) | ||
} | ||
} | ||
} | ||
_ => Ok(ValidateCallbackResult::Valid), | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this pattern not imply that
holoom_types
,jaq_wrapper
,shared_utils
aren't workspace members?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are dependency packages .. i dont think they need to be members.