Last active
October 29, 2018 20:19
-
-
Save lucksus/57f26743f9f56a940a67498e93413f7a to your computer and use it in GitHub Desktop.
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
#[derive(Serialize, Deserialize)] | |
pub struct Task { | |
text: String, | |
complete: bool, | |
} | |
define_zome! { | |
entries: [ | |
entry!( | |
name: "task", | |
description: "a thing to do", | |
sharing: Sharing::Public, | |
native_type: Task, | |
validation_package: || { | |
hdk::ValidationPackageDefinition::Entry | |
}, | |
validation: |task: Task, _ctx: hdk::ValidationData| { | |
(task.text.len() > 0) | |
.ok_or_else(|| String::from("Task text can't be empty")) | |
} | |
) | |
] | |
genesis: || { | |
Ok(()) | |
} | |
functions: { | |
main (Public) { | |
create_task: { | |
inputs: |text: String|, | |
outputs: |address: serde_json::Value|, | |
handler: handle_create_task | |
} | |
list_tasks: { | |
inputs: | |, | |
outputs: |tasks: serde_json::Value|, | |
handler: handle_list_tasks | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment