Skip to content

Commit

Permalink
ref: use our rpc instead of alchemy
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Jan 19, 2024
1 parent 217a594 commit e878c18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
10 changes: 6 additions & 4 deletions app/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import React, { useMemo } from "react";
import { WebWalletConnector } from "starknetkit/webwallet";
import { goerli, mainnet } from "@starknet-react/chains";
import { Chain, goerli, mainnet } from "@starknet-react/chains";
import {
Connector,
StarknetConfig,
alchemyProvider,
argent,
braavos,
jsonRpcProvider,
} from "@starknet-react/core";
import { StarknetIdJsProvider } from "@context/StarknetIdJsProvider";
import { ThemeProvider, createTheme } from "@mui/material";
Expand All @@ -18,8 +18,10 @@ import { getCurrentNetwork } from "@utils/network";
export function Providers({ children }: { children: React.ReactNode }) {
const network = getCurrentNetwork();
const chains = [network === "TESTNET" ? goerli : mainnet];
const provider = alchemyProvider({
apiKey: process.env.NEXT_PUBLIC_ALCHEMY_KEY as string,
const provider = jsonRpcProvider({
rpc: (_chain: Chain) => ({
nodeUrl: process.env.NEXT_PUBLIC_RPC_URL as string,
}),
});

const connectors = useMemo(
Expand Down
18 changes: 10 additions & 8 deletions context/StarknetIdJsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ export const StarknetIdJsProvider = ({ children }: { children: ReactNode }) => {
return network === "TESTNET" ? true : false;
}, []);

const provider = useMemo(() => {
return new Provider({
rpc: {
nodeUrl: process.env.NEXT_PUBLIC_RPC_URL,
},
});
}, []);

const starknetIdNavigator = useMemo(() => {
return new StarknetIdNavigator(
new Provider({
rpc: {
nodeUrl: `https://starknet-${
isTestnet ? "goerli" : "mainnet"
}.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_KEY}`,
},
}),
provider,
isTestnet
? constants.StarknetChainId.SN_GOERLI
: constants.StarknetChainId.SN_MAIN
);
}, []);
}, [provider]);

const contextValues = useMemo(() => {
return {
Expand Down

0 comments on commit e878c18

Please sign in to comment.