-
Notifications
You must be signed in to change notification settings - Fork 30
Bump Wasm to support fedimint-client-rpc #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Size Change: +569 B (+0.01%) Total Size: 7.44 MB
ℹ️ View Unchanged
|
RPCThe RPC system uses JSON messages for communication. Every request includes a request_id for tracking, and every response echoes the same request_id so the client can match responses to requests. Request FormatAll requests must conform to the RpcRequest structure.
example
Response FormatAll responses conform to the RpcResponse structure.
ExampleJoin Federation
Preview Federation
Example JavaScript Usage// Create RPC handler instance
const rpcHandler = new RpcHandler(syncHandle);
// Example request
const request = {
request_id: 1,
type: "generate_mnemonic"
};
// Send request
rpcHandler.rpc(JSON.stringify(request), (responseJson) => {
const response = JSON.parse(responseJson);
switch (response.type) {
case "data":
console.log("Data:", response.data);
break;
case "error":
console.error("Error:", response.error);
break;
case "aborted":
console.log("Request aborted");
break;
case "end":
console.log("Request complete");
break;
default:
console.warn("Unknown response type:", response.type);
}
}); Summary •Requests: Define what the client wants (e.g., generate mnemonic, join federation). •Responses: Echo the same request_id and contain either data, error, aborted, or end. •Streaming Support: Some responses may stream multiple data messages before completion. •Cancellation: Requests can be cancelled explicitly, resulting in an aborted response. |
No description provided.