Skip to content

Commit

Permalink
Ponder env (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 authored Nov 27, 2024
1 parent 1408ac4 commit 384c94f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/nextjs/app/_components/Grants/AllGrantsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
4 changes: 4 additions & 0 deletions packages/nextjs/scaffold.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type ScaffoldConfig = {
walletConnectProjectId: string;
disableBurnerWalletOnLocal: boolean;
onlyLocalBurnerWallet: boolean;
startBlock: number;
};

const scaffoldConfig = {
Expand Down Expand Up @@ -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;
4 changes: 4 additions & 0 deletions packages/ponder/.env.example
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions packages/ponder/ponder.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
7 changes: 4 additions & 3 deletions packages/ponder/src/StreamContract.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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",
Expand All @@ -30,7 +31,7 @@ ponder.on("Stream:Withdraw", async ({ event, context }) => {
builderAddress: event.args.to,
contractGrantId: event.args.grantId,
},
replacer
replacer,
),
});
} catch (error) {
Expand Down

0 comments on commit 384c94f

Please sign in to comment.