forked from holochain-immersive/holochain-lesson-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
263 lines (223 loc) · 6.93 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, viewport-fit=cover"
/>
<meta name="Description" content="Put your description here." />
<base href="/" />
<style>
html,
body {
margin: 0;
padding: 0;
font-family: sans-serif;
background-color: #ededed;
--r-main-font-size: 24px;
--r-heading-margin: 20px 0 12px 0;
}
.slides {
width: 75% !important;
}
.container {
top: 0 !important;
display: flex !important;
flex-direction: row !important;
}
.column {
display: flex;
flex-direction: column;
}
.row {
display: flex;
flex-direction: row;
}
ul {
width: 100%;
}
section {
text-align: left;
}
.popover {
position: absolute;
background-color: #4d4d4d;
padding: 1rem 2rem;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
border-radius: 10px;
width: auto;
transform: translate(16px, -15px);
max-width: 600px;
white-space: break-spaces;
}
.popover:after {
content: "";
position: absolute;
top: 6px;
left: -8px;
border-style: solid;
border-width: 18px 12px 0;
border-color: #4d4d4d transparent;
display: block;
width: 0;
z-index: 1;
transform: translate(-50%, 50%) rotate(90deg);
}
.popover .hljs-meta,
.popover .hljs-class,
.popover .hljs-keyword,
.popover .hljs-string,
.popover .hljs-title {
color: rgb(221, 221, 221) !important;
font-weight: normal;
}
.reveal pre code {
max-height: 800px !important;
}
.dna {
background-color: green;
}
.zome {
background-color: blue;
}
.coordinator-zomes {
background-color: lightblue;
}
.dna,
.cell,
.zome,
.coordinator-zomes,
.source-chain,
.happ-bundle,
.box,
.dna-bundle,
.dht-shard,
.conductor,
.happ {
display: flex;
align-items: center;
justify-content: center;
padding: 12px;
border-width: 3px;
border-color: rgb(209, 209, 209);
border-style: solid;
}
</style>
<link rel="stylesheet" href="/node_modules/reveal.js/dist/reveal.css" />
<link
rel="stylesheet"
href="/node_modules/reveal.js/dist/theme/black.css"
/>
<link
rel="stylesheet"
href="/node_modules/reveal.js/plugin/highlight/monokai.css"
/>
<title>Holochain Lesson 3</title>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>HDK: retrieving source chains</h1>
</section>
<!-- TODO: what to do in the recap? Probably we build it during the weekend -->
<section>
<fragment language="markdown" animate="by-line with-ancestry">
### query() (I)
- Retrieve the source chain for the cell that's calling "query()"
- Only way to retrieve private entries
</fragment>
<fragment animate="balanced separate-comments by-line with-ancestry">
<pre
class="fragment fade-in"
><code class="rust" data-noescape>use hdk::prelude::*;
#[hdk_extern]
fn query_my_full_chain(_: ()) -> ExternResult<Vec<Record>> {
let filter = ChainQueryFilter::new(); // We'll see more options
let my_full_chain: Vec<Record> = query(filter)?;<span class="fragment fade-in-then-out popover"><li class="fragment fade-in-then-semi-out">Does not do any network call</li><li class="fragment fade-in-then-semi-out">Records are returned in ascendent order (from oldest to newest)</li></span> // No network calls
Ok(my_full_chain)
}
</code></pre>
</fragment>
</section>
<section>
<h3>query() (II)</h3>
<fragment animate="balanced separate-comments by-line with-ancestry">
<pre
class="fragment fade-in"
><code class="rust" data-noescape>use hdk::prelude::*;
#[hdk_entry_helper]
struct Comment {
comment: String
}
#[hdk_entry_defs]
#[unit_enum(UnitEntryTypes)]
enum EntryTypes {
Comment(Comment),
}
#[hdk_extern]
fn query_my_comments(_: ()) -> ExternResult<Vec<Record>> {
let comment_entry_type: EntryType = UnitEntryTypes::Comment.try_into()?;<span class="fragment fade-in-then-out popover">Generated with "#[unit_enum(UnitEntryTypes)]"</span>
let filter = ChainQueryFilter::new().entry_type(comment_entry_type); // Filter by the given entry type
let all_my_comments = query(filter)?; // Only the records which create or update comments
Ok(all_my_comments)
}
#[hdk_extern]
fn query_all_links_i_created(_: ()) -> ExternResult<Vec<Record>> {
let filter = ChainQueryFilter::new().action_type(ActionType::CreateLink<span class="fragment fade-in-then-out popover">May be any kind of action</span>);
let all_links_i_created = query(filter)?; // Only the records whose action is of type "CreateLink"
Ok(all_links_i_created)
}
</code></pre>
</fragment>
</section>
<section>
<fragment language="markdown" animate="by-line with-ancestry">
### get_agent_activity()
- Retrieve the source chain actions for a given agent
- All actions are public in the DHT
- Doesn't return entries
</fragment>
<fragment animate="balanced separate-comments by-line with-ancestry">
<pre
class="fragment fade-in"
><code class="rust" data-noescape>use hdk::prelude::*;
#[hdk_extern]
fn get_comments_created_by(author: AgentPubKey) -> ExternResult<Vec<ActionHash>> {
let filter = ChainQueryFilter::new(); // Same options as "query"
let agent_activity = get_agent_activity(
author,<!-- TODO: fix taking into account the latest API -->
filter,
ActivityRequest::Full
)?;
}
</code></pre>
</fragment>
</section>
<section>
<h1>That's it!</h1>
</section>
</div>
</div>
<script type="module">
import Reveal from "reveal.js";
import Markdown from "reveal.js/plugin/markdown/markdown.esm.js";
import RevealHighlight from "reveal.js/plugin/highlight/highlight.esm.js";
import RevealNotes from "reveal.js/plugin/notes/notes.esm.js";
import RevealAnimateFragments from "reveal.js-animate-fragments";
import RevealEliminateEmptyLines from "reveal.js-animate-fragments";
let deck = new Reveal({
transition: "none",
plugins: [
Markdown,
RevealHighlight,
RevealNotes,
RevealAnimateFragments,
RevealEliminateEmptyLines
],
});
deck.initialize();
</script>
</body>
</html>