export interface Rpc { request(service: string, method: string, data: Uint8Array): Promise; } export class FetchRpc implements Rpc { constructor(private baseUrl: string) {} async request(service: string, method: string, data: Uint8Array): Promise { const url = `${this.baseUrl}/${service}/${method}`; // Optionally, convert or wrap data as needed by your grpc-gateway. const jsonBody = JSON.stringify({ message: Array.from(data) }); const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: jsonBody, }); if (!response.ok) { throw new Error(`HTTP error: ${response.status}`); } const responseJson = await response.json(); return new Uint8Array(responseJson.message); } }