Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Commit

Permalink
fixup nix tools and add holochain-run-dna
Browse files Browse the repository at this point in the history
  • Loading branch information
Connoropolous committed Oct 2, 2020
1 parent 61ad17a commit 2aa14cd
Show file tree
Hide file tree
Showing 19 changed files with 341 additions and 215 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/*.dna.gz
databases

conductor-config.toml
profiles_dna_address
Expand All @@ -7,7 +8,6 @@ dist
node_modules/
target/
.hc
storage
.cargo
**/.DS_Store
.prettierrc
Expand Down
62 changes: 31 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let
url = "https://github.com/${config.holonix.github.owner}/${config.holonix.github.repo}/tarball/${config.holonix.github.ref}";
sha256 = config.holonix.github.sha256;
}
) { config = config; };
) { config = config; use-stable-rust = true; };
# END HOLONIX IMPORT BOILERPLATE

in
Expand All @@ -24,6 +24,16 @@ with holonix.pkgs;
dev-shell = stdenv.mkDerivation (holonix.shell // {
name = "dev-shell";

shellHook = holonix.pkgs.lib.concatStrings [
holonix.shell.shellHook
''
cargo install --force holochain --git https://github.com/holochain/holochain.git --rev a13638dd47f09c2f6ef8a7a9ffea4f89c15f2f83
cargo install --force dna_util --git https://github.com/holochain/holochain.git --rev a13638dd47f09c2f6ef8a7a9ffea4f89c15f2f83
cd test && npm install && cd ..
npm install
''
];

buildInputs = [ ]
++ holonix.shell.buildInputs
++ config.buildInputs
Expand Down
5 changes: 1 addition & 4 deletions dnas/profiles/zomes/acorn_profiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use hdk3::prelude::*;

mod profile;

use profile::{
Profile, AGENTS_PATH,
};
use profile::{Profile, AGENTS_PATH};

#[hdk_extern]
fn init(_: ()) -> ExternResult<InitCallbackResult> {
Expand All @@ -14,7 +12,6 @@ fn init(_: ()) -> ExternResult<InitCallbackResult> {

entry_defs![Path::entry_def(), Profile::entry_def()];


// The GetResponse struct allows our zome functions to return an entry along with its
// address so that Redux can know the address of goals and edges

Expand Down
59 changes: 24 additions & 35 deletions dnas/profiles/zomes/acorn_profiles/src/profile/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use dna_help::{fetch_links, get_latest_for_entry, EntryAndHash};
use hdk3::prelude::*;
use dna_help::{
get_latest_for_entry,
fetch_links,
EntryAndHash
};

pub const AGENTS_PATH: &str = "agents";

Expand All @@ -19,9 +15,9 @@ pub struct Profile {
}

impl From<EntryAndHash<Profile>> for Profile {
fn from(entry_and_hash: EntryAndHash<Profile>) -> Self {
entry_and_hash.0
}
fn from(entry_and_hash: EntryAndHash<Profile>) -> Self {
entry_and_hash.0
}
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, SerializedBytes)]
Expand All @@ -31,12 +27,12 @@ pub struct WireEntry {
}

impl From<EntryAndHash<Profile>> for WireEntry {
fn from(entry_and_hash: EntryAndHash<Profile>) -> Self {
WireEntry {
entry: entry_and_hash.0,
address: entry_and_hash.1,
}
}
fn from(entry_and_hash: EntryAndHash<Profile>) -> Self {
WireEntry {
entry: entry_and_hash.0,
address: entry_and_hash.1,
}
}
}

#[derive(Serialize, Deserialize, SerializedBytes, Debug, Clone, PartialEq)]
Expand Down Expand Up @@ -100,14 +96,14 @@ impl<'de> Deserialize<'de> for Status {
}
}

#[hdk_extern]
fn validate(_: Entry) -> ExternResult<ValidateCallbackResult> {
// HOLD
// have to hold on this until we get more than entry in the validation callback
// which will come soon, according to David M.
let _ = debug!("in validation callback");
Ok(ValidateCallbackResult::Valid)
}
// #[hdk_extern]
// fn validate(_: Entry) -> ExternResult<ValidateCallbackResult> {
// // HOLD
// // have to hold on this until we get more than entry in the validation callback
// // which will come soon, according to David M.
// let _ = debug!("in validation callback");
// Ok(ValidateCallbackResult::Valid)
// }

#[hdk_extern]
pub fn create_whoami(entry: Profile) -> ExternResult<WireEntry> {
Expand All @@ -118,7 +114,7 @@ pub fn create_whoami(entry: Profile) -> ExternResult<WireEntry> {
let header_hash = create_entry!(entry.clone())?;

let entry_hash = hash_entry!(entry.clone())?;

// list me so anyone can see my profile
let agents_path_address = Path::from(AGENTS_PATH).hash()?;
create_link!(agents_path_address, entry_hash.clone())?;
Expand All @@ -136,10 +132,7 @@ pub fn create_whoami(entry: Profile) -> ExternResult<WireEntry> {

#[hdk_extern]
pub fn update_whoami(update: WireEntry) -> ExternResult<WireEntry> {
update_entry!(
update.address.clone(),
update.entry.clone()
)?;
update_entry!(update.address.clone(), update.entry.clone())?;
// // send update to peers
// // notify_new_agent(profile.clone())?;
Ok(update)
Expand All @@ -156,17 +149,13 @@ pub fn whoami(_: ()) -> ExternResult<WhoAmIOutput> {
// // from the UI perspective
match maybe_profile_link {
Some(profile_link) => match get_latest_for_entry::<Profile>(profile_link.target.clone())? {
Some(entry_and_hash) => {
Ok(WhoAmIOutput(Some(WireEntry::from(entry_and_hash))))
},
Some(entry_and_hash) => Ok(WhoAmIOutput(Some(WireEntry::from(entry_and_hash)))),
None => Ok(WhoAmIOutput(None)),
},
None => Ok(WhoAmIOutput(None)),
}
}



#[hdk_extern]
pub fn fetch_agents(_: ()) -> ExternResult<AgentsOutput> {
let path_hash = Path::from(AGENTS_PATH).hash()?;
Expand All @@ -177,11 +166,11 @@ pub fn fetch_agents(_: ()) -> ExternResult<AgentsOutput> {
#[hdk_extern]
fn fetch_agent_address(_: ()) -> ExternResult<AgentAddressOutput> {
let agent_info = agent_info!()?;
Ok(AgentAddressOutput(agent_info.agent_initial_pubkey.to_string()))
Ok(AgentAddressOutput(
agent_info.agent_initial_pubkey.to_string(),
))
}



// pub fn profile_def() -> ValidatingEntryType {
// entry!(
// name: "profile",
Expand Down
2 changes: 1 addition & 1 deletion dnas/projects/zomes/acorn_projects/src/project/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ pub struct Edge {
randomizer: f64,
}

crud!(Edge, edge, "edge");
crud!(Edge, edge, "edge");
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl From<EntryAndHash<EntryPoint>> for WireEntry {
}

#[derive(Serialize, Deserialize, SerializedBytes)]
pub struct VecEntryPointResponse (Vec<EntryPointResponse>);
pub struct VecEntryPointResponse(Vec<EntryPointResponse>);

// CREATE
#[hdk_extern]
Expand Down
Loading

0 comments on commit 2aa14cd

Please sign in to comment.