Skip to content

Commit

Permalink
refactor: Improve RPC configuration and remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Mar 6, 2025
1 parent 0df81db commit 63007a0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
17 changes: 17 additions & 0 deletions apps/api/src/helpers/getRpc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { LENS_MAINNET_RPCS, LENS_TESTNET_RPCS } from "@hey/data/rpcs";
import type { FallbackTransport } from "viem";
import { fallback, http } from "viem";

const getRpc = ({ mainnet }: { mainnet: boolean }): FallbackTransport => {
if (mainnet) {
return fallback(
LENS_MAINNET_RPCS.map((rpc) => http(rpc, { batch: { batchSize: 10 } }))
);
}

return fallback(
LENS_TESTNET_RPCS.map((rpc) => http(rpc, { batch: { batchSize: 10 } }))
);
};

export default getRpc;
6 changes: 4 additions & 2 deletions apps/api/src/helpers/heyWalletClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { createWalletClient, http, type Hex } from "viem";
import { IS_MAINNET } from "@hey/data/constants";
import { type Hex, createWalletClient } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import getRpc from "./getRpc";

export const heyWalletClient = createWalletClient({
account: privateKeyToAccount(process.env.PRIVATE_KEY as Hex),
transport: http("https://rpc.yoginth.com")
transport: getRpc({ mainnet: IS_MAINNET })
});
1 change: 0 additions & 1 deletion apps/api/src/routes/live/create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { LIVEPEER_KEY } from "@hey/data/constants";
import logger from "@hey/helpers/logger";
import parseJwt from "@hey/helpers/parseJwt";
import type { Request, Response } from "express";
import catchedError from "src/helpers/catchedError";
Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/components/Common/Providers/Web3Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
STATIC_IMAGES_URL,
WALLETCONNECT_PROJECT_ID
} from "@hey/data/constants";
import { LENS_TESTNET_RPCS } from "@hey/data/rpcs";
import { LENS_MAINNET_RPCS, LENS_TESTNET_RPCS } from "@hey/data/rpcs";
import { chains } from "@lens-network/sdk/viem";
import { ConnectKitProvider, getDefaultConfig } from "connectkit";
import type { FC, ReactNode } from "react";
Expand All @@ -17,11 +17,12 @@ const config = createConfig(
getDefaultConfig({
chains: [chains.testnet, chains.testnet],
transports: {
// TODO: Make this support mainnet also
[chains.testnet.id]: fallback(
LENS_TESTNET_RPCS.map((rpc) => http(rpc, { batch: true }))
LENS_MAINNET_RPCS.map((rpc) => http(rpc, { batch: { batchSize: 10 } }))
),
[chains.testnet.id]: fallback(
LENS_TESTNET_RPCS.map((rpc) => http(rpc, { batch: true }))
LENS_TESTNET_RPCS.map((rpc) => http(rpc, { batch: { batchSize: 10 } }))
)
},
walletConnectProjectId: WALLETCONNECT_PROJECT_ID,
Expand Down

0 comments on commit 63007a0

Please sign in to comment.