import { wrap, proxy } from 'comlink';

const fromWorker = (worker) => {
  const wrapped = wrap(worker);
  return {
    createProof(nodes, updates) {
      return wrapped.createProof(nodes, updates);
    },
    decodeProof(trieRootHash, nodes) {
      return wrapped.decodeProof(trieRootHash, nodes);
    },
    getRuntimeVersion(code) {
      return wrapped.getRuntimeVersion(code);
    },
    runRuntimeCall(params) {
      const { storage, ...rest } = params;
      return wrapped.runRuntimeCall(
        {
          ...rest,
          code: storage.code
        },
        proxy({
          getValue: (key) => storage.getValue(key),
          getDescendantKeys: (prefix) => storage.getDescendantKeys(prefix)
        })
      );
    }
  };
};

export { fromWorker };
//# sourceMappingURL=from-worker.js.map
