Skip to content

Commit

Permalink
Merge pull request #310 from adrianvrj/feat-308
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelAR authored Dec 20, 2024
2 parents 46cb49f + 947bc94 commit 4c86b0e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
4 changes: 4 additions & 0 deletions frontend/gostarkme-web/.env.example
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 3 additions & 3 deletions frontend/gostarkme-web/app/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -17,15 +17,15 @@ 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 = [];
for (let i = 1; i < id; i++) {
// 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) {
Expand Down
8 changes: 3 additions & 5 deletions frontend/gostarkme-web/components/modules/Fund/Fund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -18,9 +18,6 @@ import { FundWithdraw } from "./FundWithdraw";

const Fund = () => {
const wallet = useAtomValue(walletStarknetkitLatestAtom);
const [fundManagerContract, _setFundManagerContract] = useState<Contract>(
new Contract(fundManager, FUND_MANAGER_ADDR, wallet?.account)
);

const [fund, setFund] = useState<any>({});
const [loading, setLoading] = useState(true);
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion frontend/gostarkme-web/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4c86b0e

Please sign in to comment.