diff --git a/frontend/gostarkme-web/.env.example b/frontend/gostarkme-web/.env.example new file mode 100644 index 0000000..d0aa533 --- /dev/null +++ b/frontend/gostarkme-web/.env.example @@ -0,0 +1,4 @@ +NEXT_PUBLIC_APP_ROOT = "/" +NEXT_PUBLIC_CHAIN_ID = "SN_SEPOLIA" +NEXT_PUBLIC_FUND_MANAGER_ADDR = "0x05c07c43c1a4ccf22ae39de7998ff07ca380823a3cc556eff0b1187438cf7bcf" +NEXT_PUBLIC_RPC = "https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/v0_7/GG9Q64Cz4Bn1P5OY2ZIspDMSsdf_Pdl5" \ No newline at end of file diff --git a/frontend/gostarkme-web/app/app/page.tsx b/frontend/gostarkme-web/app/app/page.tsx index 6001c44..27d11bb 100644 --- a/frontend/gostarkme-web/app/app/page.tsx +++ b/frontend/gostarkme-web/app/app/page.tsx @@ -2,7 +2,7 @@ import FundCards from "@/components/dashboard/fundCard"; import Footer from "@/components/ui/Footer"; import Navbar from "@/components/ui/Navbar"; -import { FUND_MANAGER_ADDR } from "@/constants"; +import { FUND_MANAGER_ADDR, provider } from "@/constants"; import { fundAbi } from "@/contracts/abis/fund"; import { fundManager } from "@/contracts/abis/fundManager"; import React, { useEffect, useState } from "react"; @@ -17,7 +17,7 @@ const Dashboard = () => { const [loading, setLoading] = useState(true); async function getFunds() { - const fundManagerContract = new Contract(fundManager, FUND_MANAGER_ADDR); + const fundManagerContract = new Contract(fundManager, FUND_MANAGER_ADDR, provider); const id = await fundManagerContract.get_current_id(); let fundings = []; @@ -25,7 +25,7 @@ const Dashboard = () => { // GET FUND ADDRESS let fundaddr = await fundManagerContract.get_fund(i); fundaddr = "0x" + fundaddr.toString(16); - const fundContract = new Contract(fundAbi, fundaddr); + const fundContract = new Contract(fundAbi, fundaddr, provider); // GET FUND STATE let state = await fundContract.get_state(); if (state == 4 || state == 0) { diff --git a/frontend/gostarkme-web/components/modules/Fund/Fund.tsx b/frontend/gostarkme-web/components/modules/Fund/Fund.tsx index be4f5e9..d27a9a8 100644 --- a/frontend/gostarkme-web/components/modules/Fund/Fund.tsx +++ b/frontend/gostarkme-web/components/modules/Fund/Fund.tsx @@ -5,7 +5,7 @@ import starknetlogo from "@/public/icons/starklogo.png"; import { FundVote } from "./FundVote"; import { useEffect, useState } from "react"; -import { FUND_MANAGER_ADDR, upVotesNeeded } from "@/constants"; +import { FUND_MANAGER_ADDR, provider, upVotesNeeded } from "@/constants"; import Divider from "@/components/ui/Divider"; import { fundAbi } from "@/contracts/abis/fund"; import { fundManager } from "@/contracts/abis/fundManager"; @@ -18,9 +18,6 @@ import { FundWithdraw } from "./FundWithdraw"; const Fund = () => { const wallet = useAtomValue(walletStarknetkitLatestAtom); - const [fundManagerContract, _setFundManagerContract] = useState( - new Contract(fundManager, FUND_MANAGER_ADDR, wallet?.account) - ); const [fund, setFund] = useState({}); const [loading, setLoading] = useState(true); @@ -29,9 +26,10 @@ const Fund = () => { const clickedFund = useAtomValue(clickedFundState); async function getDetails() { + const fundManagerContract = new Contract(fundManager, FUND_MANAGER_ADDR, provider); let addr = await fundManagerContract.get_fund(clickedFund?.id); addr = "0x" + addr.toString(16); - const fundContract = new Contract(fundAbi, addr, wallet?.account); + const fundContract = new Contract(fundAbi, addr, provider); try { // Fetch fund details let name = await fundContract.get_name(); diff --git a/frontend/gostarkme-web/components/modules/Fund/FundWithdraw.tsx b/frontend/gostarkme-web/components/modules/Fund/FundWithdraw.tsx index cc2c592..7c1f659 100644 --- a/frontend/gostarkme-web/components/modules/Fund/FundWithdraw.tsx +++ b/frontend/gostarkme-web/components/modules/Fund/FundWithdraw.tsx @@ -7,6 +7,7 @@ import { latestTxAtom } from "@/state/latestTx"; import { useAtomValue, useSetAtom } from "jotai"; import { Contract, InvokeFunctionResponse } from "starknet"; import { useRouter } from "next/navigation"; +import { provider } from "@/constants"; interface FundWithdrawProps { addr: string, diff --git a/frontend/gostarkme-web/constants/index.ts b/frontend/gostarkme-web/constants/index.ts index 9285ae7..92d22c2 100644 --- a/frontend/gostarkme-web/constants/index.ts +++ b/frontend/gostarkme-web/constants/index.ts @@ -14,7 +14,7 @@ export const CHAIN_ID = ? constants.NetworkName.SN_MAIN : constants.NetworkName.SN_SEPOLIA -const NODE_URL = "https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/v0_7/2qi3kpZwfw6DlnjQmzL8vUh5PlqZ0Dpv"; +const NODE_URL = process.env.NEXT_PUBLIC_RPC; export const provider = new RpcProvider({ nodeUrl: NODE_URL,