Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: use our rpc instead of alchemy #468

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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