import { createRpc } from "@substrate/light-client-extension-helpers/utils"
import { BackgroundRpcSpec } from "../../../background/types"
import { CHANNEL_ID } from "../../../constants"

const port = chrome.runtime.connect({
    name: `${CHANNEL_ID}/wallet-popup`,
})
export const rpc = createRpc((msg) =>
    port.postMessage(msg),
).withClient<BackgroundRpcSpec>()
port.onMessage.addListener(rpc.handle)
