trufflesuite/truffle

View on GitHub
packages/db/src/network/fetch/networkId.ts

Summary

Maintainability
A
0 mins
Test Coverage
/**
 * @category Internal processor
 * @packageDocumentation
 */
import { logger } from "@truffle/db/logger";
const debug = logger("db:network:fetch:networkId");

import type { Process } from "@truffle/db/process";

export function* process(): Process<any, { web3: "net_version" }> {
  debug("Generating networkId fetch...");

  const response = yield {
    type: "web3",
    method: "net_version",
    params: []
  };

  const { result } = response;

  const networkId = parseInt(result);

  debug("Generated networkId fetch.");
  return networkId;
}