-
Notifications
You must be signed in to change notification settings - Fork 267
Conversation
callee_id = "test-instance-1" | ||
handle = "DPKI" | ||
handle = "test-callee" |
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.
This handle is the "instance_handle" that the bridge caller has to provide to hdk::call
to reference this bridged instance.
|
||
|
||
fn handle_call_bridge() -> JsonString { | ||
hdk::call("test-callee", "greeter", "public", "token", "hello", JsonString::from("{}")).unwrap() |
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.
"test-callee" is the handle set in the container config for this bridge. This actually has to be defined in the DNA but currently the container does not enforce these handles to match up (next PR). Then we will also have a way of defining the needed bridges in the define_zome! macro below. A bridge handle would then be like the declaration of binding: if declared in the zome as required, zome code can expect a call to such a bridge to work because the container would not load a config in which a matching bridge definition was missing..
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.
At this point, it kind of looks like hdk::call should accept a struct maybe, instead of so many params
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.
yep, though it will lose at least one again soon when the capability stuff is completely switched to tokens..
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.
exactly. also the capability name is in the current call and that will go away too.
# Conflicts: # core/src/nucleus/ribosome/api/call.rs
|
||
|
||
fn handle_call_bridge() -> JsonString { | ||
hdk::call("test-callee", "greeter", "public", "token", "hello", JsonString::from("{}")).unwrap() |
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.
At this point, it kind of looks like hdk::call should accept a struct maybe, instead of so many params
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.
This is super great. Woot!
.unwrap(); | ||
|
||
// "Holo World" comes for the callee_wat above which runs in the callee instance | ||
assert_eq!(result, JsonString::from(RawString::from("Holo World"))); |
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.
woot woot!!!
|
||
|
||
fn handle_call_bridge() -> JsonString { | ||
hdk::call("test-callee", "greeter", "public", "token", "hello", JsonString::from("{}")).unwrap() |
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.
exactly. also the capability name is in the current call and that will go away too.
Context
This is basic bridging. But no checks and no capability tokens. If the bridge is set in the config the caller can call any zome function of the callee.
hdk::call
for bridge callsAdded instance handle to
hdk::call()
, which can also behdk::THIS_INSTANCE
to call other local zomes.implement bridged call via
Context::container_api
core/src/nucleus/ribosome/api/call.rs:
Bridge roundtrip test in container_api crate
The test container config sets up a caller and a callee instance. The callee is created completely in the tests section in container.rs with WAT code. In there is a function "hello" that returns the string "Holo World" (set as ascii in WAT). The caller is the new WASM Rust project "test-bridge-caller" so I can use
hdk::call
. Test shows that "Holo World" arrives at the caller side.