Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc authored and bhargavaparoksham committed May 15, 2024
1 parent b82a230 commit f49339d
Show file tree
Hide file tree
Showing 3 changed files with 716 additions and 403 deletions.
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.71",
"@allo-team/allo-v2-sdk": "^1.0.72",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@gitcoinco/passport-sdk-types": "^0.2.0",
Expand Down
33 changes: 21 additions & 12 deletions packages/common/src/allo/backends/allo-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Erc20ABI from "../abis/erc20";
import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
import { buildUpdatedRowsOfApplicationStatuses } from "../application";
import { BigNumber, utils } from "ethers";
import { Distribution } from "@allo-team/allo-v2-sdk/dist/strategies/DonationVotingMerkleDistributionStrategy/types";

function getStrategyAddress(strategy: RoundCategory, chainId: ChainId): string {
let strategyAddresses;
Expand Down Expand Up @@ -1187,7 +1188,7 @@ export class AlloV2 implements Allo {
args.projectIdsToBePaid.includes(project.anchorAddress ?? "")
);

const projectsWithMerkleProof: ProjectWithMerkleProof[] = [];
const projectsWithMerkleProof: Distribution[] = [];

projectsToBePaid.forEach((project) => {
if (!project.index) {
Expand All @@ -1211,22 +1212,30 @@ export class AlloV2 implements Allo {
const validMerkleProof = tree.getProof(distribution);

projectsWithMerkleProof.push({
index: distribution[0],
recipientId: distribution[1],
amount: distribution[3],
merkleProof: validMerkleProof,
index: BigInt(distribution[0]),
recipientId: distribution[1] as Address,
amount: BigInt(distribution[3].toString()),
merkleProof: validMerkleProof as Address[],
});

console.log("projectsWithMerkleProof", projectsWithMerkleProof);

});

const strategy = new DonationVotingMerkleDistributionStrategy({
chain: this.chainId,
poolId: poolId,
});

const projectsWithMerkleProofBytes = serializeProjects(
projectsWithMerkleProof
const txData = strategy.distribute(
recipientIds,
projectsWithMerkleProof,
);

const txResult = await sendTransaction(this.transactionSender, {
address: this.allo.address(),
abi: AlloAbi,
functionName: "distribute",
args: [poolId, recipientIds, projectsWithMerkleProofBytes],
const txResult = await sendRawTransaction(this.transactionSender, {
to: txData.to,
data: txData.data,
value: BigInt(txData.value),
});

emit("transaction", txResult);
Expand Down
Loading

0 comments on commit f49339d

Please sign in to comment.