Skip to content

Commit

Permalink
Custom provider (#38)
Browse files Browse the repository at this point in the history
* update: button improvement

* update: burner wallet

* fix: types

* fix: rejected txs

* feat: add custom provider

* update: custom provider url

---------

Co-authored-by: Eduardo <[email protected]>
  • Loading branch information
edulanasca and smithii-tech authored Apr 9, 2024
1 parent 785110e commit ae25430
Show file tree
Hide file tree
Showing 5 changed files with 375 additions and 303 deletions.
1 change: 1 addition & 0 deletions packages/nextjs/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_PROVIDER_URL=
18 changes: 11 additions & 7 deletions packages/nextjs/components/ScaffoldStarkAppWithProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ import {useEffect, useState} from "react";
import {useTheme} from "next-themes";
import {Toaster} from "react-hot-toast";
import {
StarknetConfig,
publicProvider,
argent,
braavos,
useInjectedConnectors,
starkscan,
StarknetConfig, publicProvider, argent, braavos, useInjectedConnectors, starkscan, jsonRpcProvider, starknetChainId,
} from "@starknet-react/core";
import {Header} from "~~/components/Header";
import {Footer} from "~~/components/Footer";
import {ProgressBar} from "~~/components/scaffold-stark/ProgressBar";
import {appChains} from "~~/services/web3/connectors";
import {BurnerConnector} from "~~/services/web3/stark-burner/BurnerConnector";
import scaffoldConfig from "~~/scaffold.config";

const ScaffoldStarkApp = ({children}: { children: React.ReactNode }) => {
return (
Expand All @@ -37,6 +33,14 @@ export const ScaffoldStarkAppWithProviders = ({children,}: {
const isDarkMode = resolvedTheme === "dark";
const [mounted, setMounted] = useState(false);

const provider = scaffoldConfig.rpcProviderUrl == "" ? publicProvider() :
jsonRpcProvider({
rpc: () => ({
nodeUrl: scaffoldConfig.rpcProviderUrl,
chainId: starknetChainId(scaffoldConfig.targetNetworks[0].id)
})
})

useEffect(() => {
setMounted(true);
}, []);
Expand All @@ -49,7 +53,7 @@ export const ScaffoldStarkAppWithProviders = ({children,}: {
return (
<StarknetConfig
chains={appChains}
provider={publicProvider()}
provider={provider}
connectors={connectors}
explorer={starkscan}
>
Expand Down
Loading

0 comments on commit ae25430

Please sign in to comment.