Skip to content

Conversation

MrImmortal09
Copy link
Member

No description provided.

Copy link

changeset-bot bot commented Oct 1, 2025

⚠️ No Changeset found

Latest commit: 44af64e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Oct 1, 2025

Size Change: +569 B (+0.01%)

Total Size: 7.44 MB

Filename Size Change
packages/core/dist/index.js 1.73 kB +363 B (+26.55%) 🚨
packages/core/dist/testing.js 2.68 kB -12 B (-0.45%)
packages/transport-web/dist/worker.js 713 B -130 B (-15.42%) 👏
packages/types/dist/index.js 248 B +53 B (+27.18%) 🚨
packages/types/dist/common.js 65 B +65 B (new file) 🆕
packages/types/dist/rpc.js 230 B +230 B (new file) 🆕
ℹ️ View Unchanged
Filename Size
packages/create-fedimint-app/dist/index.mjs 17 kB
packages/react/dist/index.js 1.3 kB
packages/transport-web/dist/index.js 278 B
packages/wasm-bundler/fedimint_client_wasm_bg.wasm 3.71 MB
packages/wasm-web/fedimint_client_wasm_bg.wasm 3.71 MB

compressed-size-action

@MrImmortal09
Copy link
Member Author

MrImmortal09 commented Oct 2, 2025

RPC

The 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 Format

All requests must conform to the RpcRequest structure.

{
“request_id”: 123,
“type”: “request_type”
 ... additional payload if any
}

example

“request_id”: 1,
“type”: “join_federation”,
“invite_code”: “fed11qg…”,
“force_recover”: false,
“client_name”: "dd5135b2-c228-41b7-a4f9-3b6e7afe3088”
}

Response Format

All responses conform to the RpcResponse structure.

{
“request_id”: 123,
“type”: “response_type”
}

Example

Join Federation

{
“request_id”: 4,
“type”: “data”,
“data”: null
}

Preview Federation

{
“request_id”: 10,
“type”: “data”,
“data”: {
       “config”: {  federation config  },
       “federation_id”: “fed11qg…”
       }
}

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant