Skip to content

Commit 04b1e03

Browse files
feat: fetch direct donation contracts from chain data package
1 parent d6f1cff commit 04b1e03

File tree

4 files changed

+13
-72
lines changed

4 files changed

+13
-72
lines changed

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@allo-team/allo-v2-sdk": "^1.0.78",
2020
"@ethersproject/abstract-signer": "^5.7.0",
2121
"@ethersproject/providers": "^5.7.2",
22-
"@gitcoin/gitcoin-chain-data": "^1.0.33",
22+
"@gitcoin/gitcoin-chain-data": "^1.0.34",
2323
"@gitcoinco/passport-sdk-types": "^0.2.0",
2424
"@openzeppelin/merkle-tree": "^1.0.2",
2525
"@rainbow-me/rainbowkit": "2.1.2",

packages/common/src/allo/backends/allo-v2.ts

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -83,67 +83,6 @@ export function getAlloAddress(chainId: number) {
8383
return allo.address();
8484
}
8585

86-
export function getDirectAllocationPoolId(chainId: number) {
87-
switch (chainId) {
88-
case 11155111:
89-
return 386;
90-
case 10:
91-
return 58;
92-
case 42161:
93-
return 390;
94-
case 42220:
95-
return 12;
96-
case 8453:
97-
return 36;
98-
case 43114:
99-
return 15;
100-
case 534352:
101-
case 534353:
102-
return 22;
103-
case 250:
104-
return 4;
105-
case 1:
106-
return 11;
107-
case 1329:
108-
case 808:
109-
return 8;
110-
case 42:
111-
return 3;
112-
case 1088:
113-
return 1;
114-
default:
115-
return undefined;
116-
}
117-
}
118-
119-
export function getDirectAllocationStrategyAddress(chainId: number) {
120-
// This should be the strategy address, once the pool is created
121-
switch (chainId) {
122-
case 11155111:
123-
return "0xd60BCfa8714949c478d88da51A7450703A32Cf35";
124-
case 10:
125-
return "0x91ad709fe04e214ef53218572d8d8690a8b4fdd0";
126-
case 42161:
127-
return "0x91ad709fe04e214ef53218572d8d8690a8b4fdd0";
128-
case 42220:
129-
return "0x9da0a7978b7bd826e06800427cbf1ec1200393e3";
130-
case 8453:
131-
return "0xef78f18f49dea8b8a5caa41633bb50b0666d40f1";
132-
case 43114:
133-
return "0xcdf62dd1f9f9f412485dba39b491af9e09d81652";
134-
case 250:
135-
return "0xf4ad959b0eceab17648cb964c3a1feadba8a5053";
136-
case 1:
137-
return "0xef78f18f49dea8b8a5caa41633bb50b0666d40f1";
138-
case 42:
139-
return "0x471168a823d909fd3ffa5641757d9bb83ba5e35c";
140-
case 1088:
141-
return "0xef78f18f49dea8b8a5caa41633bb50b0666d40f1";
142-
default:
143-
return undefined;
144-
}
145-
}
146-
14786
export class AlloV2 implements Allo {
14887
private transactionSender: TransactionSender;
14988
private ipfsUploader: IpfsUploader;
@@ -1586,7 +1525,8 @@ export class AlloV2 implements Allo {
15861525
poolId: poolId,
15871526
});
15881527

1589-
const strategyAddress = getDirectAllocationStrategyAddress(this.chainId);
1528+
const strategyAddress = getChainById(this.chainId).contracts
1529+
.directAllocationStrategyAddress;
15901530

15911531
if (strategyAddress === undefined) {
15921532
return error(new AlloError("Direct allocation strategy not found"));

packages/grant-explorer/src/features/projects/ViewProject.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import { getVotingTokenOptions } from "../api/utils";
4747
import ErrorModal from "../common/ErrorModal";
4848
import ProgressModal, { errorModalDelayMs } from "../common/ProgressModal";
4949
import { useDirectAllocation } from "./hooks/useDirectAllocation";
50-
import { getDirectAllocationPoolId } from "common/dist/allo/backends/allo-v2";
5150
import { Address, getAddress, zeroAddress } from "viem";
5251
import GenericModal from "../common/GenericModal";
5352
import { InformationCircleIcon } from "@heroicons/react/24/outline";
@@ -105,7 +104,8 @@ export default function ViewProject() {
105104
const [tokenBalances, setTokenBalances] = useState<
106105
{ token: Address; balance: bigint }[]
107106
>([]);
108-
const directAllocationPoolId = getDirectAllocationPoolId(chainId ?? 1);
107+
const directAllocationPoolId = getChainById(chainId ?? 1).contracts
108+
.directAllocationPoolId;
109109
const [transactionReplaced, setTransactionReplaced] = useState(false);
110110
const { projectId } = useParams();
111111

@@ -455,7 +455,8 @@ export default function ViewProject() {
455455
if (
456456
directDonationAmount === undefined ||
457457
allo === null ||
458-
payoutToken === undefined
458+
payoutToken === undefined ||
459+
directAllocationPoolId === undefined
459460
) {
460461
return;
461462
}
@@ -466,7 +467,7 @@ export default function ViewProject() {
466467
try {
467468
let requireTokenApproval = false;
468469

469-
const poolId = getDirectAllocationPoolId(chainId ?? 1)?.toString();
470+
const poolId = directAllocationPoolId.toString();
470471

471472
const recipient = project?.roles?.filter(
472473
(role) => role.role === "OWNER"

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)