import { providers } from "ethers";
export const publicClientToProvider = (publicClient) => {
  var _a, _b;
  const { chain, transport } = publicClient;
  const network = {
    chainId: chain.id,
    name: chain.name,
    ensAddress: (_b = (_a = chain.contracts) === null || _a === void 0 ? void 0 : _a.ensRegistry) === null || _b === void 0 ? void 0 : _b.address,
  };
  if (transport.type === 'fallback')
    return new providers.FallbackProvider(transport.transports.map(({ value }) => new providers.JsonRpcProvider(value === null || value === void 0 ? void 0 : value.url, network)));
  return new providers.JsonRpcProvider(transport.url, network);
};
export const walletClientToSigner = (walletClient) => {
  var _a, _b;
  const { account, chain, transport } = walletClient;
  const network = {
    chainId: chain.id,
    name: chain.name,
    ensAddress: (_b = (_a = chain.contracts) === null || _a === void 0 ? void 0 : _a.ensRegistry) === null || _b === void 0 ? void 0 : _b.address,
  };
  const provider = new providers.Web3Provider(transport, network);
  const signer = provider.getSigner(account.address);
  return signer;
};
//# sourceMappingURL=adapters.js.map
