Skip to content

Revert "feat: add direct donate button" #3559

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 1 commit into from
Jul 19, 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 @@ -16,7 +16,7 @@
"test:watch": "vitest watch"
},
"dependencies": {
"@allo-team/allo-v2-sdk": "^1.0.77",
"@allo-team/allo-v2-sdk": "^1.0.76",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@gitcoin/gitcoin-chain-data": "^1.0.17",
Expand Down
17 changes: 0 additions & 17 deletions packages/common/src/allo/allo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,6 @@ export interface Allo {
indexingStatus: Result<null>;
}
>;

directAllocation: (args: {
tokenAddress: Address;
poolId: string;
amount: bigint;
recipient: Address;
nonce: bigint;
requireTokenApproval?: boolean;
}) => AlloOperation<
Result<null>,
{
tokenApprovalStatus: Result<TransactionReceipt | null>;
transaction: Result<Hex>;
transactionStatus: Result<TransactionReceipt>;
indexingStatus: Result<null>;
}
>;
}

export { AlloOperation };
Expand Down
22 changes: 0 additions & 22 deletions packages/common/src/allo/backends/allo-v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1310,28 +1310,6 @@ export class AlloV1 implements Allo {
return error(result);
});
}

directAllocation(args: {
tokenAddress: Address;
poolId: string;
amount: bigint;
recipient: Address;
nonce: bigint;
requireTokenApproval?: boolean;
}): AlloOperation<
Result<null>,
{
tokenApprovalStatus: Result<TransactionReceipt | null>;
transaction: Result<Hex>;
transactionStatus: Result<TransactionReceipt>;
indexingStatus: Result<null>;
}
> {
return new AlloOperation(async () => {
const result = new AlloError(`Unsupported on v1 ${args}`);
return error(result);
});
}
}
// todo: move this out?
export type CreateRoundArgs = {
Expand Down
127 changes: 0 additions & 127 deletions packages/common/src/allo/backends/allo-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
AlloAbi,
Allo as AlloV2Contract,
CreateProfileArgs,
DirectAllocationStrategy,
DirectGrantsLiteStrategy,
DirectGrantsLiteStrategyTypes,
DonationVotingMerkleDistributionDirectTransferStrategyAbi,
Expand Down Expand Up @@ -83,24 +82,6 @@ export function getAlloAddress(chainId: number) {
return allo.address();
}

export function getDirectAllocationPoolId(chainId: number) {
switch (chainId) {
case 11155111:
return 386;
default:
return undefined;
}
}

export function getDirectAllocationStrategyAddress(chainId: number) {
switch (chainId) {
case 11155111:
return "0xd60BCfa8714949c478d88da51A7450703A32Cf35";
default:
return undefined;
}
}

export class AlloV2 implements Allo {
private transactionSender: TransactionSender;
private ipfsUploader: IpfsUploader;
Expand Down Expand Up @@ -1454,114 +1435,6 @@ export class AlloV2 implements Allo {
return success(null);
});
}

directAllocation(args: {
tokenAddress: Address;
poolId: string;
amount: bigint;
recipient: Address;
nonce: bigint;
requireTokenApproval?: boolean;
}): AlloOperation<
Result<null>,
{
tokenApprovalStatus: Result<TransactionReceipt | null>;
transaction: Result<Hex>;
transactionStatus: Result<TransactionReceipt>;
indexingStatus: Result<null>;
}
> {
return new AlloOperation(async ({ emit }) => {
if (isNaN(Number(args.poolId))) {
return error(new AlloError("Pool ID is not a valid Allo V2 pool ID"));
}

const poolId = BigInt(args.poolId);

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

const strategyAddress = getDirectAllocationStrategyAddress(this.chainId);

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

if (args.tokenAddress === zeroAddress || !args.requireTokenApproval) {
emit("tokenApprovalStatus", success(null));
} else {
const approvalTx = await sendTransaction(this.transactionSender, {
address: args.tokenAddress,
abi: Erc20ABI,
functionName: "approve",
args: [strategyAddress, args.amount],
});

if (approvalTx.type === "error") {
const result = new AlloError(
"Failed to approve token transfer",
approvalTx.error
);
emit("tokenApprovalStatus", error(result));
return error(result);
}
try {
const receipt = await this.transactionSender.wait(approvalTx.value);
emit("tokenApprovalStatus", success(receipt));
} catch (err) {
const result = new AlloError("Failed to approve token transfer", err);
emit("tokenApprovalStatus", error(result));
return error(result);
}
}

let _token = args.tokenAddress;
if (_token === zeroAddress) {
_token = getAddress(NATIVE);
}

const txData = strategy.getAllocateData({
profileOwner: args.recipient,
amount: BigInt(args.amount.toString()),
token: _token,
nonce: args.nonce,
});

const tx = await sendRawTransaction(this.transactionSender, {
to: txData.to,
data: txData.data,
value: BigInt(txData.value),
});

emit("transaction", tx);

if (tx.type === "error") {
return tx;
}

let receipt: TransactionReceipt;

try {
receipt = await this.transactionSender.wait(tx.value);
emit("transactionStatus", success(receipt));
} catch (err) {
const result = new AlloError("Failed to fund round", err);
emit("transactionStatus", error(result));
return error(result);
}

await this.waitUntilIndexerSynced({
chainId: this.chainId,
blockNumber: receipt.blockNumber,
});

emit("indexingStatus", success(null));

return success(null);
});
}
}

export function serializeProject(project: ProjectWithMerkleProof) {
Expand Down
7 changes: 0 additions & 7 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,3 @@ export type InputType =
export type DeepRequired<T> = {
[K in keyof T]: Required<DeepRequired<T[K]>>;
};

export type Allocation = {
profileOwner: `0x${string}`;
amount: bigint;
token: `0x${string}`;
nonce: bigint;
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface InfoModalProps {
}

export default function InfoModal({
title = "",
title = "Information Title",
titleSize = "sm",
isOpen = false,
setIsOpen = () => {
Expand Down
Loading
Loading