Skip to content

feat: fetch direct donation contracts from chain data package #3611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@allo-team/allo-v2-sdk": "^1.0.78",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@gitcoin/gitcoin-chain-data": "^1.0.33",
"@gitcoin/gitcoin-chain-data": "^1.0.34",
"@gitcoinco/passport-sdk-types": "^0.2.0",
"@openzeppelin/merkle-tree": "^1.0.2",
"@rainbow-me/rainbowkit": "2.1.2",
Expand Down
64 changes: 2 additions & 62 deletions packages/common/src/allo/backends/allo-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,67 +83,6 @@ export function getAlloAddress(chainId: number) {
return allo.address();
}

export function getDirectAllocationPoolId(chainId: number) {
switch (chainId) {
case 11155111:
return 386;
case 10:
return 58;
case 42161:
return 390;
case 42220:
return 12;
case 8453:
return 36;
case 43114:
return 15;
case 534352:
case 534353:
return 22;
case 250:
return 4;
case 1:
return 11;
case 1329:
case 808:
return 8;
case 42:
return 3;
case 1088:
return 1;
default:
return undefined;
}
}

export function getDirectAllocationStrategyAddress(chainId: number) {
// This should be the strategy address, once the pool is created
switch (chainId) {
case 11155111:
return "0xd60BCfa8714949c478d88da51A7450703A32Cf35";
case 10:
return "0x91ad709fe04e214ef53218572d8d8690a8b4fdd0";
case 42161:
return "0x91ad709fe04e214ef53218572d8d8690a8b4fdd0";
case 42220:
return "0x9da0a7978b7bd826e06800427cbf1ec1200393e3";
case 8453:
return "0xef78f18f49dea8b8a5caa41633bb50b0666d40f1";
case 43114:
return "0xcdf62dd1f9f9f412485dba39b491af9e09d81652";
case 250:
return "0xf4ad959b0eceab17648cb964c3a1feadba8a5053";
case 1:
return "0xef78f18f49dea8b8a5caa41633bb50b0666d40f1";
case 42:
return "0x471168a823d909fd3ffa5641757d9bb83ba5e35c";
case 1088:
return "0xef78f18f49dea8b8a5caa41633bb50b0666d40f1";
default:
return undefined;
}
}

export class AlloV2 implements Allo {
private transactionSender: TransactionSender;
private ipfsUploader: IpfsUploader;
Expand Down Expand Up @@ -1586,7 +1525,8 @@ export class AlloV2 implements Allo {
poolId: poolId,
});

const strategyAddress = getDirectAllocationStrategyAddress(this.chainId);
const strategyAddress = getChainById(this.chainId).contracts
.directAllocationStrategyAddress;

if (strategyAddress === undefined) {
return error(new AlloError("Direct allocation strategy not found"));
Expand Down
19 changes: 0 additions & 19 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,25 +477,6 @@ export function isChainIdSupported(chainId: number) {
return getChainById(chainId) !== undefined;
}

const gg20Rounds = [
//GG20 rounds
{ roundId: "23", chainId: 42161 }, // Hackathon Alumni
{ roundId: "24", chainId: 42161 }, // ENS
{ roundId: "25", chainId: 42161 }, // dApps & Apps
{ roundId: "26", chainId: 42161 }, // WEB3 Infrastructure
{ roundId: "27", chainId: 42161 }, // Developer Tooling
{ roundId: "28", chainId: 42161 }, // Hypercerts Ecosystem
{ roundId: "29", chainId: 42161 }, // Climate Solutions
{ roundId: "31", chainId: 42161 }, // Open Civics
{ roundId: "36", chainId: 42161 }, // Regenerative Land Projects
{ roundId: "39", chainId: 42161 }, // DeSci
{ roundId: "9", chainId: 10 }, // Token Engineering Commons (TEC)
];

export function isGG20Round(roundId: string, chainId: number) {
return gg20Rounds.some((r) => r.roundId === roundId && r.chainId === chainId);
}

export function isLitUnavailable(chainId: number) {
return [
4201, // LUKSO_TESTNET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import { getVotingTokenOptions } from "../api/utils";
import ErrorModal from "../common/ErrorModal";
import ProgressModal, { errorModalDelayMs } from "../common/ProgressModal";
import { useDirectAllocation } from "./hooks/useDirectAllocation";
import { getDirectAllocationPoolId } from "common/dist/allo/backends/allo-v2";
import { Address, getAddress, zeroAddress } from "viem";
import GenericModal from "../common/GenericModal";
import { InformationCircleIcon } from "@heroicons/react/24/outline";
Expand Down Expand Up @@ -105,7 +104,8 @@ export default function ViewProject() {
const [tokenBalances, setTokenBalances] = useState<
{ token: Address; balance: bigint }[]
>([]);
const directAllocationPoolId = getDirectAllocationPoolId(chainId ?? 1);
const directAllocationPoolId = getChainById(chainId ?? 1).contracts
.directAllocationPoolId;
const [transactionReplaced, setTransactionReplaced] = useState(false);
const { projectId } = useParams();

Expand Down Expand Up @@ -455,7 +455,8 @@ export default function ViewProject() {
if (
directDonationAmount === undefined ||
allo === null ||
payoutToken === undefined
payoutToken === undefined ||
directAllocationPoolId === undefined
) {
return;
}
Expand All @@ -466,7 +467,7 @@ export default function ViewProject() {
try {
let requireTokenApproval = false;

const poolId = getDirectAllocationPoolId(chainId ?? 1)?.toString();
const poolId = directAllocationPoolId.toString();

const recipient = project?.roles?.filter(
(role) => role.role === "OWNER"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
UploadIcon,
} from "@heroicons/react/solid";
import { useDropzone } from "react-dropzone";
import { classNames, isGG20Round, getPayoutTokens, TToken } from "common";
import { classNames, getPayoutTokens, TToken } from "common";
import { Button } from "common/src/styles";
import { useDebugMode, useRoundMatchingFunds } from "../../../hooks";
import {
Expand Down Expand Up @@ -384,9 +384,8 @@ function ViewRoundResults({

const disableRoundSaturationControls = Math.round(roundSaturation) >= 100;

const sybilDefense = isGG20Round(round.id, chain.id)
? "passport-mbds"
: round.roundMetadata?.quadraticFundingConfig?.sybilDefense;
const sybilDefense =
round.roundMetadata?.quadraticFundingConfig?.sybilDefense;

const isCustomResults =
(sybilDefense === "passport-mbds" && isRecommendedDistribution) ||
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading