diff --git a/packages/nextjs/app/_components/Grants/AllGrantsList.tsx b/packages/nextjs/app/_components/Grants/AllGrantsList.tsx index b92d2e6..ade246f 100644 --- a/packages/nextjs/app/_components/Grants/AllGrantsList.tsx +++ b/packages/nextjs/app/_components/Grants/AllGrantsList.tsx @@ -18,7 +18,8 @@ export const AllGrantsList = ({ allGrants }: AllGrantsListProps) => { const [statusFilter, setStatusFilter] = useState("all"); const maxStage = useMemo(() => { - return Math.max(...allGrants.flatMap(grant => grant.stages.map(stage => stage.stageNumber))); + const stageNumbers = allGrants.flatMap(grant => grant.stages.map(stage => stage.stageNumber)); + return stageNumbers.length > 0 ? Math.max(...stageNumbers) : 0; }, [allGrants]); const filteredGrants = useMemo(() => { diff --git a/packages/nextjs/scaffold.config.ts b/packages/nextjs/scaffold.config.ts index 011c305..c3362ea 100644 --- a/packages/nextjs/scaffold.config.ts +++ b/packages/nextjs/scaffold.config.ts @@ -7,6 +7,7 @@ export type ScaffoldConfig = { walletConnectProjectId: string; disableBurnerWalletOnLocal: boolean; onlyLocalBurnerWallet: boolean; + startBlock: number; }; const scaffoldConfig = { @@ -34,6 +35,9 @@ const scaffoldConfig = { // disable burner wallet for all networks disableBurnerWalletOnLocal: true, + + // start blocknumber for contract deployment indexing + startBlock: 0, } as const satisfies ScaffoldConfig; export default scaffoldConfig; diff --git a/packages/ponder/.env.example b/packages/ponder/.env.example new file mode 100644 index 0000000..6ccf2f0 --- /dev/null +++ b/packages/ponder/.env.example @@ -0,0 +1,4 @@ +PONDER_RPC_URL_31337=http://127.0.0.1:8545/ +PONDER_RPC_URL_10= +PONDER_RPC_URL_11155420= +APP_URL=http://localhost:3000 diff --git a/packages/ponder/ponder.config.ts b/packages/ponder/ponder.config.ts index ef4c025..bff129b 100644 --- a/packages/ponder/ponder.config.ts +++ b/packages/ponder/ponder.config.ts @@ -23,11 +23,10 @@ const contracts = Object.fromEntries( abi: deployedContracts[targetNetwork.id][contractName].abi, address: deployedContracts[targetNetwork.id][contractName].address, // TODO: Change startBlock when deploying - startBlock: - deployedContracts[targetNetwork.id][contractName].startBlock || 0, + startBlock: scaffoldConfig.startBlock || 0, }, ]; - }) + }), ); export default createConfig({ diff --git a/packages/ponder/src/StreamContract.ts b/packages/ponder/src/StreamContract.ts index e098968..d48aa5c 100644 --- a/packages/ponder/src/StreamContract.ts +++ b/packages/ponder/src/StreamContract.ts @@ -1,5 +1,7 @@ import { ponder } from "@/generated"; +const APP_URL = process.env.APP_URL || "http://localhost:3000"; + ponder.on("Stream:Withdraw", async ({ event, context }) => { try { const { db } = context; @@ -17,8 +19,7 @@ ponder.on("Stream:Withdraw", async ({ event, context }) => { }, }); - // TODO: Change url before deploying - await fetch("http://localhost:3000/api/stages/revalidate-status", { + await fetch(`${APP_URL}/api/stages/revalidate-status`, { method: "POST", headers: { "Content-Type": "application/json", @@ -30,7 +31,7 @@ ponder.on("Stream:Withdraw", async ({ event, context }) => { builderAddress: event.args.to, contractGrantId: event.args.grantId, }, - replacer + replacer, ), }); } catch (error) {