Skip to content

chore: add/remove pool manager #3430

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

Closed
wants to merge 2 commits into from
Closed
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
24 changes: 24 additions & 0 deletions packages/common/src/allo/allo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,30 @@ export interface Allo {
indexingStatus: Result<null>;
}
>;

addPoolManager: (args: {
poolId: Hex;
manager: Address;
}) => AlloOperation<
Result<null>,
{
transaction: Result<Hex>;
transactionStatus: Result<TransactionReceipt>;
indexingStatus: Result<null>;
}
>;

removePoolManager: (args: {
poolId: Hex;
manager: Address;
}) => AlloOperation<
Result<null>,
{
transaction: Result<Hex>;
transactionStatus: Result<TransactionReceipt>;
indexingStatus: Result<null>;
}
>;
}

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

addPoolManager(args: { poolId: string; manager: Address }): AlloOperation<
Result<null>,
{
transaction: Result<Hex>;
transactionStatus: Result<TransactionReceipt>;
indexingStatus: Result<null>;
}
> {
return new AlloOperation(async ({ emit }) => {
const result = new AlloError("Unsupported on v1");
return error(result);
});
}

removePoolManager(args: { poolId: string; manager: Address }): AlloOperation<
Result<null>,
{
transaction: Result<Hex>;
transactionStatus: Result<TransactionReceipt>;
indexingStatus: Result<null>;
}
> {
return new AlloOperation(async ({ emit }) => {
const result = new AlloError("Unsupported on v1");
return error(result);
});
}
}

// todo: move this out?
Expand Down
94 changes: 94 additions & 0 deletions packages/common/src/allo/backends/allo-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,100 @@ export class AlloV2 implements Allo {
return success(null);
});
}

addPoolManager(args: { poolId: string; manager: Address }): AlloOperation<
Result<null>,
{
transaction: Result<Hex>;
transactionStatus: Result<TransactionReceipt>;
indexingStatus: Result<null>;
}
> {
return new AlloOperation(async ({ emit }) => {
const txData = this.allo.addPoolManager(
BigInt(args.poolId),
args.manager
);

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

emit("transaction", txResult);

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

let receipt: TransactionReceipt;
try {
receipt = await this.transactionSender.wait(txResult.value);
emit("transactionStatus", success(receipt));
} catch (err) {
const result = new AlloError("Failed to add pool manager");
emit("transactionStatus", error(result));
return error(result);
}

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

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

return success(null);
});
}

removePoolManager(args: { poolId: string; manager: Address }): AlloOperation<
Result<null>,
{
transaction: Result<Hex>;
transactionStatus: Result<TransactionReceipt>;
indexingStatus: Result<null>;
}
> {
return new AlloOperation(async ({ emit }) => {
const txData = this.allo.removePoolManager(
BigInt(args.poolId),
args.manager
);

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

emit("transaction", txResult);

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

let receipt: TransactionReceipt;
try {
receipt = await this.transactionSender.wait(txResult.value);
emit("transactionStatus", success(receipt));
} catch (err) {
const result = new AlloError("Failed to add pool manager");
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