Two packages:
- @dao-xyz/borsh — Core Borsh serializer with decorators.
- @dao-xyz/borsh-rpc — Lightweight RPC over Borsh.
This root README gives a quick taste. Full documentation lives in each subpackage README.
import { deserialize, field, serialize } from "@dao-xyz/borsh";
class User {
@field({ type: "u32" })
id: number;
@field({ type: "string" })
name: string;
constructor(init: User) {
this.id = init.id;
this.name = init.name;
}
}
const bytes = serialize(new User({ id: 1, name: "alice" }));
const u = deserialize(bytes, User);
Full docs: ./packages/borsh/README.md
import { field } from "@dao-xyz/borsh";
import {
LoopbackPair,
bindService,
createProxyFromService,
method,
service,
} from "@dao-xyz/borsh-rpc";
class Payload {
@field({ type: "u8" })
x = 0;
}
@service()
class API {
@method({ args: "u32", returns: "u32" })
addOne(n: number) {
return n + 1;
}
}
const loop = new LoopbackPair();
const unsub = bindService(API, loop.a);
const client = createProxyFromService(API, loop.b);
await client.addOne(41); // 42
unsub();
Full docs: ./packages/rpc/README.md
yarn install
yarn build
yarn workspaces:test
Apache-2.0 and MIT. See LICENSE files.