Skip to content

Commit

Permalink
feat: add direct grants v2
Browse files Browse the repository at this point in the history
Author:    0xKurt <[email protected]>

fix: donations/when application is null (#3411)

* fix: donations/when application is null

* remove log

updated url

update env

fix tests

remove react() plugin

fix placeholder error
  • Loading branch information
0xKurt committed May 8, 2024
1 parent 2ee436d commit 83b9ffd
Show file tree
Hide file tree
Showing 54 changed files with 9,095 additions and 6,017 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
"test:data-layer": "turbo run test --filter=data-layer"
},
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"turbo": "^1.12.3"
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^17.8.1",
"turbo": "^1.13.3"
},
"dependencies": {
"concurrently": "^8.2.2",
"prettier": "^3.0.3"
"prettier": "^3.2.5"
},
"pnpm": {
"overrides": {
Expand Down
2 changes: 2 additions & 0 deletions packages/builder/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function Header({
</Link>
<button
type="button"
aria-label="Toggle Menu"
onClick={() => setNavbarOpen(!navbarOpen)}
className="lg:hidden"
>
Expand Down Expand Up @@ -88,6 +89,7 @@ export default function Header({
<button
type="button"
className="underline"
aria-label="Switch to Allo v2"
onClick={(e) => {
e.preventDefault();
switchToVersion("allo-v2");
Expand Down
4 changes: 4 additions & 0 deletions packages/builder/src/components/application/AboutProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export function AboutProject(props: {
target="_blank"
rel="noreferrer"
className="text-base font-normal text-black"
aria-label="Website Link"
>
<DetailSummary
text={`${website}`}
Expand All @@ -105,6 +106,7 @@ export function AboutProject(props: {
target="_blank"
rel="noreferrer"
className="text-base font-normal text-black"
aria-label="Twitter Link"
>
<DetailSummary
text={projectTwitter}
Expand All @@ -123,6 +125,7 @@ export function AboutProject(props: {
target="_blank"
rel="noreferrer"
className="text-base font-normal text-black"
aria-label="GitHub Link"
>
<DetailSummary
text={`${userGithub}`}
Expand All @@ -141,6 +144,7 @@ export function AboutProject(props: {
target="_blank"
rel="noreferrer"
className="text-base font-normal text-black"
aria-label="GitHub Link"
>
<DetailSummary
text={`${projectGithub}`}
Expand Down
7 changes: 6 additions & 1 deletion packages/builder/src/components/base/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export default function Toast({
}`}
>
<div className="flex items-start">{children}</div>
<button type="button" onClick={onClose} className="inline-flex">
<button
type="button"
onClick={onClose}
className="inline-flex"
aria-label="Add"
>
<Cross color={colors["quaternary-text"]} />
</button>
</div>
Expand Down
54 changes: 34 additions & 20 deletions packages/builder/src/components/rounds/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,16 @@ function ShowRound() {
let votingHasStarted = false;
let votingHasEnded = false;

// covers QF and DF application and voting periods condition evaluation
const isDirectRound: boolean =
roundState?.round?.payoutStrategy === RoundCategory.Direct;

const roundStartTime = !isDirectRound
? roundState?.round?.applicationsStartTime
: roundState?.round?.roundStartTime;
const roundEndTime = !isDirectRound
? roundState?.round?.applicationsEndTime
: roundState?.round?.roundEndTime;

if (
roundState?.round &&
roundState?.round?.applicationsStartTime !== undefined &&
Expand Down Expand Up @@ -177,6 +186,9 @@ function ShowRound() {
applicationsHaveEnded,
votingHasStarted,
votingHasEnded,
isDirectRound,
roundStartTime,
roundEndTime,
};
}, shallowEqual);

Expand All @@ -192,15 +204,22 @@ function ShowRound() {
);

const renderRoundDate = () =>
roundData && (
roundData &&
(props.isDirectRound ? (
<>
{formatTimeUTC(roundData.roundStartTime)} -{" "}
{isInfinite(roundData.roundEndTime) || !roundData.roundEndTime
{formatTimeUTC(props.roundStartTime as number)} -{" "}
{isInfinite(props.roundEndTime as number) || !props.roundEndTime
? "No End Date"
: formatTimeUTC(roundData.roundEndTime)}
{}
: formatTimeUTC(props.roundEndTime)}
</>
);
) : (
<>
{formatTimeUTC(Number(props.roundStartTime))} -{" "}
{isInfinite(Number(props.roundEndTime)) || !props.roundEndTime
? "No End Date"
: formatTimeUTC(props.roundEndTime)}
</>
));

const [, setRoundToApply] = useLocalStorage("roundToApply", null);
const [roundApplicationModal, setToggleRoundApplicationModal] =
Expand Down Expand Up @@ -241,7 +260,7 @@ function ShowRound() {
setRoundData(props.round);

if (!props.round.tags.includes(alloVersion)) {
const roundVersion = props.round.tags.find((tag) =>
const roundVersion = props.round.tags.find((tag: string) =>
tag.startsWith("allo-")
);
if (roundVersion === undefined) {
Expand Down Expand Up @@ -342,7 +361,6 @@ function ShowRound() {
</div>
);
}
const isDirectRound = props.round?.payoutStrategy === RoundCategory.Direct;

return (
<div
Expand All @@ -357,23 +375,19 @@ function ShowRound() {
{roundData?.roundMetadata.name}
</h2>
<div className="flex flex-col mt-3 mb-8 text-secondary-text">
{/* <div className="flex flex-1 flex-col mt-12">
<span>Matching Funds Available:</span>
<span>$XXX,XXX</span>
</div> */}
<div className="flex flex-1 flex-col mt-8">
<span>{roundData?.roundMetadata.eligibility?.description}</span>
</div>
{!isDirectRound && (
<div className="flex flex-1 flex-col mt-8">
<span className="mb-2">Application Period:</span>
<span>{renderApplicationDate()}</span>
</div>
{!props.isDirectRound && (
<div className="flex flex-1 flex-col mt-8">
<span className="mb-2">Application Period:</span>
<span>{renderApplicationDate()}</span>
<span className="mb-2">Round Dates:</span>
<span>{renderRoundDate()}</span>
</div>
)}
<div className="flex flex-1 flex-col mt-8">
<span className="mb-2">Round Dates:</span>
<span>{renderRoundDate()}</span>
</div>
<div className="flex flex-1 flex-col mt-8">
<span className="mb-2">Eligibility Requirements:</span>
{roundData?.roundMetadata?.eligibility?.requirements.map(
Expand Down
5 changes: 3 additions & 2 deletions packages/builder/src/utils/components.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isInfiniteDate } from "common";
import { getConfig } from "common/src/config";
import PinataClient from "common/src/services/pinata";
import { DefaultProjectBanner, DefaultProjectLogo } from "../assets";
Expand Down Expand Up @@ -67,7 +68,7 @@ export const formatTimeUTC = (ts: number) => {
export const formatDateFromString = (ts: string) =>
new Date(ts).toLocaleDateString();

export const isInfinite = (number: Number) =>
number === Number.MAX_SAFE_INTEGER || !number;
export const isInfinite = (number: Number): boolean =>
isInfiniteDate(new Date(number.toString()));

export const formatDateAsNumber = (ts: string) => Date.parse(ts) / 1000;
2 changes: 1 addition & 1 deletion packages/common/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ REACT_APP_SUBGRAPH_ZKSYNC_MAINNET_API="https://api.studio.thegraph.com/query/453
REACT_APP_GRANTS_STACK_SEARCH_API_BASE_URL="https://gitcoin-search-dev.fly.dev"
REACT_APP_SUBGRAPH_BASE_API="https://api.studio.thegraph.com/query/45391/grants-round-base/v0.0.1"
REACT_APP_SUBGRAPH_SCROLL_API="https://api.studio.thegraph.com/query/45391/grants-round-scroll/v0.0.2"
REACT_APP_ALLO_API_URL="https://indexer-staging.fly.dev/graphql"
REACT_APP_ALLO_API_URL="https://grants-stack-indexer-v2.gitcoin.co/graphql"
REACT_APP_PINATA_JWT=token-test
REACT_APP_PINATA_BASE_URL=http://localhost
REACT_APP_SUBGRAPH_SEPOLIA_API=”https://api.thegraph.com/subgraphs/name/bhargavaparoksham/grants-round-sepolia-testnet”
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test:watch": "vitest watch"
},
"dependencies": {
"@allo-team/allo-v2-sdk": "^1.0.61",
"@allo-team/allo-v2-sdk": "1.0.67",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@gitcoinco/passport-sdk-types": "^0.2.0",
Expand Down
18 changes: 18 additions & 0 deletions packages/common/src/allo/allo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export interface Allo {
index: number;
status: ApplicationStatus;
}[];
strategy?: RoundCategory;
}) => AlloOperation<
Result<void>,
{
Expand Down Expand Up @@ -213,6 +214,23 @@ export interface Allo {
indexingStatus: Result<null>;
}
>;

payoutDirectGrants: (args: {
roundId: Hex | number;
token: Hex;
amount: bigint;
recipientAddress: Hex;
recipientId: Hex;
vault?: Hex;
applicationIndex?: number;
}) => AlloOperation<
Result<{ blockNumber: bigint }>,
{
transaction: Result<Hex>;
transactionStatus: Result<TransactionReceipt>;
indexingStatus: Result<void>;
}
>;
}

export { AlloOperation };
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/allo/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function buildUpdatedRowsOfApplicationStatuses(args: {
statusToNumber: (status: ApplicationStatus) => bigint;
bitsPerStatus: number;
}): { index: bigint; statusRow: bigint }[] {
if (args.bitsPerStatus % 2 !== 0) {
if (args.bitsPerStatus > 1 && args.bitsPerStatus % 2 !== 0) {
throw new Error("bitsPerStatus must be a multiple of 2");
}

Expand Down
Loading

0 comments on commit 83b9ffd

Please sign in to comment.