import { take } from 'rxjs';
import { getStorageCodecs } from './codecs.js';

const prequeries = ["Mmr.Nodes", "Paras.Heads"];
const runPrequeries = (chain) => {
  chain.finalized$.pipe(take(1)).subscribe({
    next: async (hash) => {
      const block = chain.getBlock(hash);
      for (const pre of prequeries) {
        const [pallet, entry] = pre.split(".");
        const codec = await getStorageCodecs(block, pallet, entry);
        if (codec) {
          chain.getStorageDescendants(hash, codec.keys.enc()).catch(() => {
          });
        }
      }
    },
    error: () => {
    }
  });
};

export { runPrequeries };
//# sourceMappingURL=prequeries.js.map
