1use crate::prelude::*;
2use hdi::hdi::HdiT;
3
4pub const HDK_NOT_REGISTERED: &str = "HDK not registered";
5
6use core::cell::RefCell;
9use std::rc::Rc;
10
11#[cfg(any(feature = "mock", not(target_arch = "wasm32")))]
12thread_local!(pub static HDK: RefCell<Rc<dyn HdkT>> = RefCell::new(Rc::new(ErrHdk)));
13
14#[cfg(all(not(feature = "mock"), target_arch = "wasm32"))]
15thread_local!(pub static HDK: RefCell<Rc<dyn HdkT>> = RefCell::new(Rc::new(HostHdk)));
16
17pub trait HdkT: HdiT {
24 fn get_agent_activity(
26 &self,
27 get_agent_activity_input: GetAgentActivityInput,
28 ) -> ExternResult<AgentActivity>;
29 fn query(&self, filter: ChainQueryFilter) -> ExternResult<Vec<Record>>;
30 fn sign(&self, sign: Sign) -> ExternResult<Signature>;
32 fn sign_ephemeral(&self, sign_ephemeral: SignEphemeral) -> ExternResult<EphemeralSignatures>;
33 fn create(&self, create_input: CreateInput) -> ExternResult<ActionHash>;
35 fn update(&self, update_input: UpdateInput) -> ExternResult<ActionHash>;
36 fn delete(&self, delete_input: DeleteInput) -> ExternResult<ActionHash>;
37 fn get(&self, get_input: Vec<GetInput>) -> ExternResult<Vec<Option<Record>>>;
38 fn get_details(&self, get_input: Vec<GetInput>) -> ExternResult<Vec<Option<Details>>>;
39 #[cfg(feature = "unstable-countersigning")]
41 fn accept_countersigning_preflight_request(
42 &self,
43 preflight_request: PreflightRequest,
44 ) -> ExternResult<PreflightRequestAcceptance>;
45 fn agent_info(&self, agent_info_input: ()) -> ExternResult<AgentInfo>;
47 fn call_info(&self, call_info_input: ()) -> ExternResult<CallInfo>;
48 fn create_link(&self, create_link_input: CreateLinkInput) -> ExternResult<ActionHash>;
50 fn delete_link(&self, delete_link_input: DeleteLinkInput) -> ExternResult<ActionHash>;
51 fn get_links(&self, get_links_input: Vec<GetLinksInput>) -> ExternResult<Vec<Vec<Link>>>;
52 fn get_links_details(
53 &self,
54 get_links_input: Vec<GetLinksInput>,
55 ) -> ExternResult<Vec<LinkDetails>>;
56 fn count_links(&self, query: LinkQuery) -> ExternResult<usize>;
57 #[cfg(feature = "unstable-functions")]
59 fn block_agent(&self, block_agent_input: BlockAgentInput) -> ExternResult<()>;
60 #[cfg(feature = "unstable-functions")]
61 fn unblock_agent(&self, unblock_agent_input: BlockAgentInput) -> ExternResult<()>;
62 fn call(&self, call: Vec<Call>) -> ExternResult<Vec<ZomeCallResponse>>;
63 fn emit_signal(&self, app_signal: AppSignal) -> ExternResult<()>;
64 fn send_remote_signal(&self, remote_signal: RemoteSignal) -> ExternResult<()>;
65 fn random_bytes(&self, number_of_bytes: u32) -> ExternResult<Bytes>;
67 fn sys_time(&self, sys_time_input: ()) -> ExternResult<Timestamp>;
69 fn schedule(&self, scheduled_fn: String) -> ExternResult<()>;
70 fn x_salsa20_poly1305_shared_secret_create_random(
72 &self,
73 key_ref: Option<XSalsa20Poly1305KeyRef>,
74 ) -> ExternResult<XSalsa20Poly1305KeyRef>;
75 fn x_salsa20_poly1305_shared_secret_export(
76 &self,
77 x_salsa20_poly1305_shared_secret_export: XSalsa20Poly1305SharedSecretExport,
78 ) -> ExternResult<XSalsa20Poly1305EncryptedData>;
79 fn x_salsa20_poly1305_shared_secret_ingest(
80 &self,
81 x_salsa20_poly1305_shared_secret_ingest: XSalsa20Poly1305SharedSecretIngest,
82 ) -> ExternResult<XSalsa20Poly1305KeyRef>;
83 fn x_salsa20_poly1305_encrypt(
84 &self,
85 x_salsa20_poly1305_encrypt: XSalsa20Poly1305Encrypt,
86 ) -> ExternResult<XSalsa20Poly1305EncryptedData>;
87 fn create_x25519_keypair(&self, create_x25519_keypair_input: ()) -> ExternResult<X25519PubKey>;
88 fn x_25519_x_salsa20_poly1305_encrypt(
89 &self,
90 x_25519_x_salsa20_poly1305_encrypt: X25519XSalsa20Poly1305Encrypt,
91 ) -> ExternResult<XSalsa20Poly1305EncryptedData>;
92 fn ed_25519_x_salsa20_poly1305_encrypt(
93 &self,
94 ed_25519_x_salsa20_poly1305_encrypt: Ed25519XSalsa20Poly1305Encrypt,
95 ) -> ExternResult<XSalsa20Poly1305EncryptedData>;
96 fn create_clone_cell(&self, input: CreateCloneCellInput) -> ExternResult<ClonedCell>;
98 fn disable_clone_cell(&self, input: DisableCloneCellInput) -> ExternResult<()>;
99 fn enable_clone_cell(&self, input: EnableCloneCellInput) -> ExternResult<ClonedCell>;
100 fn delete_clone_cell(&self, input: DeleteCloneCellInput) -> ExternResult<()>;
101 fn close_chain(&self, input: CloseChainInput) -> ExternResult<ActionHash>;
103 fn open_chain(&self, input: OpenChainInput) -> ExternResult<ActionHash>;
104 fn get_validation_receipts(
106 &self,
107 input: GetValidationReceiptsInput,
108 ) -> ExternResult<Vec<ValidationReceiptSet>>;
109}
110
111#[cfg(feature = "mock")]
112mockall::mock! {
113 pub HdkT {}
114
115 impl HdkT for HdkT {
116 fn get_agent_activity(
118 &self,
119 get_agent_activity_input: GetAgentActivityInput,
120 ) -> ExternResult<AgentActivity>;
121 fn query(&self, filter: ChainQueryFilter) -> ExternResult<Vec<Record>>;
122 fn sign(&self, sign: Sign) -> ExternResult<Signature>;
124 fn sign_ephemeral(&self, sign_ephemeral: SignEphemeral) -> ExternResult<EphemeralSignatures>;
125 fn create(&self, create_input: CreateInput) -> ExternResult<ActionHash>;
127 fn update(&self, update_input: UpdateInput) -> ExternResult<ActionHash>;
128 fn delete(&self, delete_input: DeleteInput) -> ExternResult<ActionHash>;
129 fn get(&self, get_input: Vec<GetInput>) -> ExternResult<Vec<Option<Record>>>;
130 fn get_details(&self, get_input: Vec<GetInput>) -> ExternResult<Vec<Option<Details>>>;
131 fn accept_countersigning_preflight_request(
133 &self,
134 preflight_request: PreflightRequest,
135 ) -> ExternResult<PreflightRequestAcceptance>;
136 fn agent_info(&self, agent_info_input: ()) -> ExternResult<AgentInfo>;
138 fn call_info(&self, call_info_input: ()) -> ExternResult<CallInfo>;
139 fn create_link(&self, create_link_input: CreateLinkInput) -> ExternResult<ActionHash>;
141 fn delete_link(&self, delete_link_input: DeleteLinkInput) -> ExternResult<ActionHash>;
142 fn get_links(&self, get_links_input: Vec<GetLinksInput>) -> ExternResult<Vec<Vec<Link>>>;
143 fn get_links_details(
144 &self,
145 get_links_input: Vec<GetLinksInput>,
146 ) -> ExternResult<Vec<LinkDetails>>;
147 fn count_links(&self, query: LinkQuery) -> ExternResult<usize>;
148 fn block_agent(&self, block_agent_input: BlockAgentInput) -> ExternResult<()>;
150 fn unblock_agent(&self, unblock_agent_input: BlockAgentInput) -> ExternResult<()>;
151 fn call(&self, call: Vec<Call>) -> ExternResult<Vec<ZomeCallResponse>>;
152 fn emit_signal(&self, app_signal: AppSignal) -> ExternResult<()>;
153 fn send_remote_signal(&self, remote_signal: RemoteSignal) -> ExternResult<()>;
154 fn random_bytes(&self, number_of_bytes: u32) -> ExternResult<Bytes>;
156 fn sys_time(&self, sys_time_input: ()) -> ExternResult<Timestamp>;
158 fn schedule(&self, scheduled_fn: String) -> ExternResult<()>;
159 fn x_salsa20_poly1305_shared_secret_create_random(
161 &self,
162 key_ref: Option<XSalsa20Poly1305KeyRef>,
163 ) -> ExternResult<XSalsa20Poly1305KeyRef>;
164 fn x_salsa20_poly1305_shared_secret_export(
165 &self,
166 x_salsa20_poly1305_shared_secret_export: XSalsa20Poly1305SharedSecretExport,
167 ) -> ExternResult<XSalsa20Poly1305EncryptedData>;
168 fn x_salsa20_poly1305_shared_secret_ingest(
169 &self,
170 x_salsa20_poly1305_shared_secret_ingest: XSalsa20Poly1305SharedSecretIngest,
171 ) -> ExternResult<XSalsa20Poly1305KeyRef>;
172 fn x_salsa20_poly1305_encrypt(
173 &self,
174 x_salsa20_poly1305_encrypt: XSalsa20Poly1305Encrypt,
175 ) -> ExternResult<XSalsa20Poly1305EncryptedData>;
176 fn create_x25519_keypair(&self, create_x25519_keypair_input: ()) -> ExternResult<X25519PubKey>;
177 fn x_25519_x_salsa20_poly1305_encrypt(
178 &self,
179 x_25519_x_salsa20_poly1305_encrypt: X25519XSalsa20Poly1305Encrypt,
180 ) -> ExternResult<XSalsa20Poly1305EncryptedData>;
181 fn ed_25519_x_salsa20_poly1305_encrypt(
182 &self,
183 ed_25519_x_salsa20_poly1305_encrypt: Ed25519XSalsa20Poly1305Encrypt,
184 ) -> ExternResult<XSalsa20Poly1305EncryptedData>;
185 fn create_clone_cell(&self, input: CreateCloneCellInput) -> ExternResult<ClonedCell>;
186 fn disable_clone_cell(&self, input: DisableCloneCellInput) -> ExternResult<()>;
187 fn enable_clone_cell(&self, input: EnableCloneCellInput) -> ExternResult<ClonedCell>;
188 fn delete_clone_cell(&self, input: DeleteCloneCellInput) -> ExternResult<()>;
189 fn close_chain(&self, input: CloseChainInput) -> ExternResult<ActionHash>;
190 fn open_chain(&self, input: OpenChainInput) -> ExternResult<ActionHash>;
191 fn get_validation_receipts(&self, input: GetValidationReceiptsInput) -> ExternResult<Vec<ValidationReceiptSet>>;
192 }
193
194 impl HdiT for HdkT {
195 fn verify_signature(&self, verify_signature: VerifySignature) -> ExternResult<bool>;
196 fn must_get_entry(&self, must_get_entry_input: MustGetEntryInput) -> ExternResult<EntryHashed>;
197 fn must_get_action(
198 &self,
199 must_get_action_input: MustGetActionInput,
200 ) -> ExternResult<SignedActionHashed>;
201 fn must_get_valid_record(
202 &self,
203 must_get_valid_record_input: MustGetValidRecordInput,
204 ) -> ExternResult<Record>;
205 fn must_get_agent_activity(
206 &self,
207 must_get_agent_activity_input: MustGetAgentActivityInput,
208 ) -> ExternResult<Vec<RegisterAgentActivity>>;
209 fn dna_info(&self, dna_info_input: ()) -> ExternResult<DnaInfo>;
211 fn zome_info(&self, zome_info_input: ()) -> ExternResult<ZomeInfo>;
212 fn trace(&self, trace_msg: TraceMsg) -> ExternResult<()>;
214 fn x_salsa20_poly1305_decrypt(
216 &self,
217 x_salsa20_poly1305_decrypt: XSalsa20Poly1305Decrypt,
218 ) -> ExternResult<Option<XSalsa20Poly1305Data>>;
219 fn x_25519_x_salsa20_poly1305_decrypt(
220 &self,
221 x_25519_x_salsa20_poly1305_decrypt: X25519XSalsa20Poly1305Decrypt,
222 ) -> ExternResult<Option<XSalsa20Poly1305Data>>;
223 fn ed_25519_x_salsa20_poly1305_decrypt(
224 &self,
225 ed_25519_x_salsa20_poly1305_decrypt: Ed25519XSalsa20Poly1305Decrypt,
226 ) -> ExternResult<XSalsa20Poly1305Data>;
227 }
228
229}
230
231pub struct ErrHdk;
234
235impl ErrHdk {
236 fn err<T>() -> ExternResult<T> {
237 Err(wasm_error!(WasmErrorInner::Guest(
238 HDK_NOT_REGISTERED.to_string()
239 )))
240 }
241}
242
243impl HdiT for ErrHdk {
245 fn verify_signature(&self, _verify_signature: VerifySignature) -> ExternResult<bool> {
246 Self::err()
247 }
248
249 fn must_get_entry(
250 &self,
251 _must_get_entry_input: MustGetEntryInput,
252 ) -> ExternResult<EntryHashed> {
253 Self::err()
254 }
255
256 fn must_get_action(
257 &self,
258 _must_get_action_input: MustGetActionInput,
259 ) -> ExternResult<SignedActionHashed> {
260 Self::err()
261 }
262
263 fn must_get_valid_record(
264 &self,
265 _must_get_valid_record_input: MustGetValidRecordInput,
266 ) -> ExternResult<Record> {
267 Self::err()
268 }
269
270 fn must_get_agent_activity(
271 &self,
272 _: MustGetAgentActivityInput,
273 ) -> ExternResult<Vec<RegisterAgentActivity>> {
274 Self::err()
275 }
276
277 fn dna_info(&self, _dna_info_input: ()) -> ExternResult<DnaInfo> {
278 Self::err()
279 }
280
281 fn zome_info(&self, _zome_info_input: ()) -> ExternResult<ZomeInfo> {
282 Self::err()
283 }
284
285 fn trace(&self, _: TraceMsg) -> ExternResult<()> {
286 Self::err()
287 }
288
289 fn x_salsa20_poly1305_decrypt(
290 &self,
291 _x_salsa20_poly1305_decrypt: XSalsa20Poly1305Decrypt,
292 ) -> ExternResult<Option<XSalsa20Poly1305Data>> {
293 Self::err()
294 }
295
296 fn x_25519_x_salsa20_poly1305_decrypt(
297 &self,
298 _x_25519_x_salsa20_poly1305_decrypt: X25519XSalsa20Poly1305Decrypt,
299 ) -> ExternResult<Option<XSalsa20Poly1305Data>> {
300 Self::err()
301 }
302
303 fn ed_25519_x_salsa20_poly1305_decrypt(
304 &self,
305 _ed_25519_x_salsa20_poly1305_decrypt: Ed25519XSalsa20Poly1305Decrypt,
306 ) -> ExternResult<XSalsa20Poly1305Data> {
307 Self::err()
308 }
309}
310
311impl HdkT for ErrHdk {
313 fn get_agent_activity(&self, _: GetAgentActivityInput) -> ExternResult<AgentActivity> {
314 Self::err()
315 }
316 fn query(&self, _: ChainQueryFilter) -> ExternResult<Vec<Record>> {
317 Self::err()
318 }
319 fn sign(&self, _: Sign) -> ExternResult<Signature> {
320 Self::err()
321 }
322 fn sign_ephemeral(&self, _: SignEphemeral) -> ExternResult<EphemeralSignatures> {
323 Self::err()
324 }
325 fn create(&self, _: CreateInput) -> ExternResult<ActionHash> {
326 Self::err()
327 }
328 fn update(&self, _: UpdateInput) -> ExternResult<ActionHash> {
329 Self::err()
330 }
331 fn delete(&self, _: DeleteInput) -> ExternResult<ActionHash> {
332 Self::err()
333 }
334 fn get(&self, _: Vec<GetInput>) -> ExternResult<Vec<Option<Record>>> {
335 Self::err()
336 }
337 fn get_details(&self, _: Vec<GetInput>) -> ExternResult<Vec<Option<Details>>> {
338 Self::err()
339 }
340 #[cfg(feature = "unstable-countersigning")]
342 fn accept_countersigning_preflight_request(
343 &self,
344 _: PreflightRequest,
345 ) -> ExternResult<PreflightRequestAcceptance> {
346 Self::err()
347 }
348 fn agent_info(&self, _: ()) -> ExternResult<AgentInfo> {
349 Self::err()
350 }
351 fn call_info(&self, _: ()) -> ExternResult<CallInfo> {
352 Self::err()
353 }
354 fn create_link(&self, _: CreateLinkInput) -> ExternResult<ActionHash> {
356 Self::err()
357 }
358 fn delete_link(&self, _: DeleteLinkInput) -> ExternResult<ActionHash> {
359 Self::err()
360 }
361 fn get_links(&self, _: Vec<GetLinksInput>) -> ExternResult<Vec<Vec<Link>>> {
362 Self::err()
363 }
364 fn get_links_details(&self, _: Vec<GetLinksInput>) -> ExternResult<Vec<LinkDetails>> {
365 Self::err()
366 }
367 fn count_links(&self, _: LinkQuery) -> ExternResult<usize> {
368 Self::err()
369 }
370 #[cfg(feature = "unstable-functions")]
372 fn block_agent(&self, _: BlockAgentInput) -> ExternResult<()> {
373 Self::err()
374 }
375 #[cfg(feature = "unstable-functions")]
376 fn unblock_agent(&self, _: BlockAgentInput) -> ExternResult<()> {
377 Self::err()
378 }
379 fn call(&self, _: Vec<Call>) -> ExternResult<Vec<ZomeCallResponse>> {
380 Self::err()
381 }
382 fn emit_signal(&self, _: AppSignal) -> ExternResult<()> {
383 Self::err()
384 }
385 fn send_remote_signal(&self, _: RemoteSignal) -> ExternResult<()> {
386 Self::err()
387 }
388 fn random_bytes(&self, _: u32) -> ExternResult<Bytes> {
390 Self::err()
391 }
392 fn sys_time(&self, _: ()) -> ExternResult<Timestamp> {
394 Self::err()
395 }
396 fn schedule(&self, _: String) -> ExternResult<()> {
397 Self::err()
398 }
399
400 fn x_salsa20_poly1305_shared_secret_create_random(
402 &self,
403 _key_ref: Option<XSalsa20Poly1305KeyRef>,
404 ) -> ExternResult<XSalsa20Poly1305KeyRef> {
405 Self::err()
406 }
407
408 fn x_salsa20_poly1305_shared_secret_export(
409 &self,
410 _x_salsa20_poly1305_shared_secret_export: XSalsa20Poly1305SharedSecretExport,
411 ) -> ExternResult<XSalsa20Poly1305EncryptedData> {
412 Self::err()
413 }
414
415 fn x_salsa20_poly1305_shared_secret_ingest(
416 &self,
417 _x_salsa20_poly1305_shared_secret_ingest: XSalsa20Poly1305SharedSecretIngest,
418 ) -> ExternResult<XSalsa20Poly1305KeyRef> {
419 Self::err()
420 }
421
422 fn x_salsa20_poly1305_encrypt(
423 &self,
424 _x_salsa20_poly1305_encrypt: XSalsa20Poly1305Encrypt,
425 ) -> ExternResult<XSalsa20Poly1305EncryptedData> {
426 Self::err()
427 }
428
429 fn create_x25519_keypair(
430 &self,
431 _create_x25519_keypair_input: (),
432 ) -> ExternResult<X25519PubKey> {
433 Self::err()
434 }
435
436 fn x_25519_x_salsa20_poly1305_encrypt(
437 &self,
438 _x_25519_x_salsa20_poly1305_encrypt: X25519XSalsa20Poly1305Encrypt,
439 ) -> ExternResult<XSalsa20Poly1305EncryptedData> {
440 Self::err()
441 }
442
443 fn ed_25519_x_salsa20_poly1305_encrypt(
444 &self,
445 _ed_25519_x_salsa20_poly1305_encrypt: Ed25519XSalsa20Poly1305Encrypt,
446 ) -> ExternResult<XSalsa20Poly1305EncryptedData> {
447 Self::err()
448 }
449
450 fn create_clone_cell(&self, _input: CreateCloneCellInput) -> ExternResult<ClonedCell> {
452 Self::err()
453 }
454
455 fn disable_clone_cell(&self, _input: DisableCloneCellInput) -> ExternResult<()> {
456 Self::err()
457 }
458
459 fn enable_clone_cell(&self, _input: EnableCloneCellInput) -> ExternResult<ClonedCell> {
460 Self::err()
461 }
462
463 fn delete_clone_cell(&self, _input: DeleteCloneCellInput) -> ExternResult<()> {
464 Self::err()
465 }
466
467 fn close_chain(&self, _input: CloseChainInput) -> ExternResult<ActionHash> {
469 Self::err()
470 }
471
472 fn open_chain(&self, _input: OpenChainInput) -> ExternResult<ActionHash> {
473 Self::err()
474 }
475
476 fn get_validation_receipts(
478 &self,
479 _input: GetValidationReceiptsInput,
480 ) -> ExternResult<Vec<ValidationReceiptSet>> {
481 Self::err()
482 }
483}
484
485pub struct HostHdk;
487
488#[cfg(all(not(feature = "mock"), target_arch = "wasm32"))]
489use hdi::hdi::HostHdi;
490
491#[cfg(all(not(feature = "mock"), target_arch = "wasm32"))]
492impl HdiT for HostHdk {
493 fn verify_signature(&self, verify_signature: VerifySignature) -> ExternResult<bool> {
494 HostHdi::new().verify_signature(verify_signature)
495 }
496 fn must_get_entry(&self, must_get_entry_input: MustGetEntryInput) -> ExternResult<EntryHashed> {
497 HostHdi::new().must_get_entry(must_get_entry_input)
498 }
499 fn must_get_action(
500 &self,
501 must_get_action_input: MustGetActionInput,
502 ) -> ExternResult<SignedActionHashed> {
503 HostHdi::new().must_get_action(must_get_action_input)
504 }
505 fn must_get_valid_record(
506 &self,
507 must_get_valid_record_input: MustGetValidRecordInput,
508 ) -> ExternResult<Record> {
509 HostHdi::new().must_get_valid_record(must_get_valid_record_input)
510 }
511 fn must_get_agent_activity(
512 &self,
513 must_get_agent_activity_input: MustGetAgentActivityInput,
514 ) -> ExternResult<Vec<RegisterAgentActivity>> {
515 HostHdi::new().must_get_agent_activity(must_get_agent_activity_input)
516 }
517 fn dna_info(&self, _: ()) -> ExternResult<DnaInfo> {
518 HostHdi::new().dna_info(())
519 }
520 fn zome_info(&self, _: ()) -> ExternResult<ZomeInfo> {
521 HostHdi::new().zome_info(())
522 }
523 fn trace(&self, m: TraceMsg) -> ExternResult<()> {
524 HostHdi::new().trace(m)
525 }
526 fn x_salsa20_poly1305_decrypt(
527 &self,
528 x_salsa20_poly1305_decrypt: XSalsa20Poly1305Decrypt,
529 ) -> ExternResult<Option<XSalsa20Poly1305Data>> {
530 HostHdi::new().x_salsa20_poly1305_decrypt(x_salsa20_poly1305_decrypt)
531 }
532 fn x_25519_x_salsa20_poly1305_decrypt(
533 &self,
534 x_25519_x_salsa20_poly1305_decrypt: X25519XSalsa20Poly1305Decrypt,
535 ) -> ExternResult<Option<XSalsa20Poly1305Data>> {
536 HostHdi::new().x_25519_x_salsa20_poly1305_decrypt(x_25519_x_salsa20_poly1305_decrypt)
537 }
538 fn ed_25519_x_salsa20_poly1305_decrypt(
539 &self,
540 ed_25519_x_salsa20_poly1305_decrypt: Ed25519XSalsa20Poly1305Decrypt,
541 ) -> ExternResult<XSalsa20Poly1305Data> {
542 HostHdi::new().ed_25519_x_salsa20_poly1305_decrypt(ed_25519_x_salsa20_poly1305_decrypt)
543 }
544}
545
546#[cfg(all(not(feature = "mock"), target_arch = "wasm32"))]
551impl HdkT for HostHdk {
552 fn get_agent_activity(
553 &self,
554 get_agent_activity_input: GetAgentActivityInput,
555 ) -> ExternResult<AgentActivity> {
556 host_call::<GetAgentActivityInput, AgentActivity>(
557 __hc__get_agent_activity_1,
558 get_agent_activity_input,
559 )
560 }
561 fn query(&self, filter: ChainQueryFilter) -> ExternResult<Vec<Record>> {
562 host_call::<ChainQueryFilter, Vec<Record>>(__hc__query_1, filter)
563 }
564 fn sign(&self, sign: Sign) -> ExternResult<Signature> {
565 host_call::<Sign, Signature>(__hc__sign_1, sign)
566 }
567 fn sign_ephemeral(&self, sign_ephemeral: SignEphemeral) -> ExternResult<EphemeralSignatures> {
568 host_call::<SignEphemeral, EphemeralSignatures>(__hc__sign_ephemeral_1, sign_ephemeral)
569 }
570 fn create(&self, create_input: CreateInput) -> ExternResult<ActionHash> {
571 host_call::<CreateInput, ActionHash>(__hc__create_1, create_input)
572 }
573 fn update(&self, update_input: UpdateInput) -> ExternResult<ActionHash> {
574 host_call::<UpdateInput, ActionHash>(__hc__update_1, update_input)
575 }
576 fn delete(&self, hash: DeleteInput) -> ExternResult<ActionHash> {
577 host_call::<DeleteInput, ActionHash>(__hc__delete_1, hash)
578 }
579 fn get(&self, get_inputs: Vec<GetInput>) -> ExternResult<Vec<Option<Record>>> {
580 host_call::<Vec<GetInput>, Vec<Option<Record>>>(__hc__get_1, get_inputs)
581 }
582 fn get_details(&self, get_inputs: Vec<GetInput>) -> ExternResult<Vec<Option<Details>>> {
583 host_call::<Vec<GetInput>, Vec<Option<Details>>>(__hc__get_details_1, get_inputs)
584 }
585 #[cfg(feature = "unstable-countersigning")]
586 fn accept_countersigning_preflight_request(
588 &self,
589 preflight_request: PreflightRequest,
590 ) -> ExternResult<PreflightRequestAcceptance> {
591 host_call::<PreflightRequest, PreflightRequestAcceptance>(
592 __hc__accept_countersigning_preflight_request_1,
593 preflight_request,
594 )
595 }
596 fn agent_info(&self, _: ()) -> ExternResult<AgentInfo> {
597 host_call::<(), AgentInfo>(__hc__agent_info_1, ())
598 }
599 fn call_info(&self, _: ()) -> ExternResult<CallInfo> {
600 host_call::<(), CallInfo>(__hc__call_info_1, ())
601 }
602 fn create_link(&self, create_link_input: CreateLinkInput) -> ExternResult<ActionHash> {
603 host_call::<CreateLinkInput, ActionHash>(__hc__create_link_1, create_link_input)
604 }
605 fn delete_link(&self, delete_link_input: DeleteLinkInput) -> ExternResult<ActionHash> {
606 host_call::<DeleteLinkInput, ActionHash>(__hc__delete_link_1, delete_link_input)
607 }
608 fn get_links(&self, get_links_input: Vec<GetLinksInput>) -> ExternResult<Vec<Vec<Link>>> {
609 host_call::<Vec<GetLinksInput>, Vec<Vec<Link>>>(__hc__get_links_1, get_links_input)
610 }
611 fn get_links_details(
612 &self,
613 get_links_input: Vec<GetLinksInput>,
614 ) -> ExternResult<Vec<LinkDetails>> {
615 host_call::<Vec<GetLinksInput>, Vec<LinkDetails>>(
616 __hc__get_links_details_1,
617 get_links_input,
618 )
619 }
620 fn count_links(&self, query: LinkQuery) -> ExternResult<usize> {
621 host_call::<LinkQuery, usize>(__hc__count_links_1, query)
622 }
623 #[cfg(feature = "unstable-functions")]
624 fn block_agent(&self, block_agent_input: BlockAgentInput) -> ExternResult<()> {
625 host_call::<BlockAgentInput, ()>(__hc__block_agent_1, block_agent_input)
626 }
627 #[cfg(feature = "unstable-functions")]
628 fn unblock_agent(&self, unblock_agent_input: BlockAgentInput) -> ExternResult<()> {
629 host_call::<BlockAgentInput, ()>(__hc__unblock_agent_1, unblock_agent_input)
630 }
631 fn call(&self, call_input: Vec<Call>) -> ExternResult<Vec<ZomeCallResponse>> {
632 host_call::<Vec<Call>, Vec<ZomeCallResponse>>(__hc__call_1, call_input)
633 }
634 fn emit_signal(&self, app_signal: AppSignal) -> ExternResult<()> {
635 host_call::<AppSignal, ()>(__hc__emit_signal_1, app_signal)
636 }
637 fn send_remote_signal(&self, remote_signal: RemoteSignal) -> ExternResult<()> {
638 host_call::<RemoteSignal, ()>(__hc__send_remote_signal_1, remote_signal)
639 }
640 fn random_bytes(&self, number_of_bytes: u32) -> ExternResult<Bytes> {
641 host_call::<u32, Bytes>(__hc__random_bytes_1, number_of_bytes)
642 }
643 fn sys_time(&self, _: ()) -> ExternResult<Timestamp> {
644 host_call::<(), Timestamp>(__hc__sys_time_1, ())
645 }
646 fn schedule(&self, scheduled_fn: String) -> ExternResult<()> {
647 host_call::<String, ()>(__hc__schedule_1, scheduled_fn)
648 }
649
650 fn x_salsa20_poly1305_shared_secret_create_random(
651 &self,
652 key_ref: Option<XSalsa20Poly1305KeyRef>,
653 ) -> ExternResult<XSalsa20Poly1305KeyRef> {
654 host_call::<Option<XSalsa20Poly1305KeyRef>, XSalsa20Poly1305KeyRef>(
655 __hc__x_salsa20_poly1305_shared_secret_create_random_1,
656 key_ref,
657 )
658 }
659
660 fn x_salsa20_poly1305_shared_secret_export(
661 &self,
662 x_salsa20_poly1305_shared_secret_export: XSalsa20Poly1305SharedSecretExport,
663 ) -> ExternResult<XSalsa20Poly1305EncryptedData> {
664 host_call::<XSalsa20Poly1305SharedSecretExport, XSalsa20Poly1305EncryptedData>(
665 __hc__x_salsa20_poly1305_shared_secret_export_1,
666 x_salsa20_poly1305_shared_secret_export,
667 )
668 }
669
670 fn x_salsa20_poly1305_shared_secret_ingest(
671 &self,
672 x_salsa20_poly1305_shared_secret_ingest: XSalsa20Poly1305SharedSecretIngest,
673 ) -> ExternResult<XSalsa20Poly1305KeyRef> {
674 host_call::<XSalsa20Poly1305SharedSecretIngest, XSalsa20Poly1305KeyRef>(
675 __hc__x_salsa20_poly1305_shared_secret_ingest_1,
676 x_salsa20_poly1305_shared_secret_ingest,
677 )
678 }
679
680 fn x_salsa20_poly1305_encrypt(
681 &self,
682 x_salsa20_poly1305_encrypt: XSalsa20Poly1305Encrypt,
683 ) -> ExternResult<XSalsa20Poly1305EncryptedData> {
684 host_call::<XSalsa20Poly1305Encrypt, XSalsa20Poly1305EncryptedData>(
685 __hc__x_salsa20_poly1305_encrypt_1,
686 x_salsa20_poly1305_encrypt,
687 )
688 }
689
690 fn create_x25519_keypair(&self, _: ()) -> ExternResult<X25519PubKey> {
691 host_call::<(), X25519PubKey>(__hc__create_x25519_keypair_1, ())
692 }
693
694 fn x_25519_x_salsa20_poly1305_encrypt(
695 &self,
696 x_25519_x_salsa20_poly1305_encrypt: X25519XSalsa20Poly1305Encrypt,
697 ) -> ExternResult<XSalsa20Poly1305EncryptedData> {
698 host_call::<X25519XSalsa20Poly1305Encrypt, XSalsa20Poly1305EncryptedData>(
699 __hc__x_25519_x_salsa20_poly1305_encrypt_1,
700 x_25519_x_salsa20_poly1305_encrypt,
701 )
702 }
703
704 fn ed_25519_x_salsa20_poly1305_encrypt(
705 &self,
706 ed_25519_x_salsa20_poly1305_encrypt: Ed25519XSalsa20Poly1305Encrypt,
707 ) -> ExternResult<XSalsa20Poly1305EncryptedData> {
708 host_call::<Ed25519XSalsa20Poly1305Encrypt, XSalsa20Poly1305EncryptedData>(
709 __hc__ed_25519_x_salsa20_poly1305_encrypt_1,
710 ed_25519_x_salsa20_poly1305_encrypt,
711 )
712 }
713
714 fn create_clone_cell(&self, input: CreateCloneCellInput) -> ExternResult<ClonedCell> {
715 host_call::<CreateCloneCellInput, ClonedCell>(__hc__create_clone_cell_1, input)
716 }
717
718 fn disable_clone_cell(&self, input: DisableCloneCellInput) -> ExternResult<()> {
719 host_call::<DisableCloneCellInput, ()>(__hc__disable_clone_cell_1, input)
720 }
721
722 fn enable_clone_cell(&self, input: EnableCloneCellInput) -> ExternResult<ClonedCell> {
723 host_call::<EnableCloneCellInput, ClonedCell>(__hc__enable_clone_cell_1, input)
724 }
725
726 fn delete_clone_cell(&self, input: DeleteCloneCellInput) -> ExternResult<()> {
727 host_call::<DeleteCloneCellInput, ()>(__hc__delete_clone_cell_1, input)
728 }
729
730 fn close_chain(&self, input: CloseChainInput) -> ExternResult<ActionHash> {
731 host_call::<CloseChainInput, ActionHash>(__hc__close_chain_1, input)
732 }
733
734 fn open_chain(&self, input: OpenChainInput) -> ExternResult<ActionHash> {
735 host_call::<OpenChainInput, ActionHash>(__hc__open_chain_1, input)
736 }
737
738 fn get_validation_receipts(
739 &self,
740 input: GetValidationReceiptsInput,
741 ) -> ExternResult<Vec<ValidationReceiptSet>> {
742 host_call::<GetValidationReceiptsInput, Vec<ValidationReceiptSet>>(
743 __hc__get_validation_receipts_1,
744 input,
745 )
746 }
747}
748
749pub fn set_hdk<H>(hdk: H)
753where
754 H: HdkT + 'static,
755{
756 let hdk = Rc::new(hdk);
757 let hdk2 = hdk.clone();
758 HDK.with(|h| {
759 *h.borrow_mut() = hdk2;
760 });
761 hdi::hdi::HDI.with(|h| {
762 *h.borrow_mut() = hdk;
763 });
764}