From 070f424a7c51964969a1404b26cc3756d64545ad Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Mon, 13 May 2024 12:46:28 +0530 Subject: [PATCH 1/2] chore: add/remove pool manager --- packages/common/src/allo/backends/allo-v2.ts | 94 ++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/packages/common/src/allo/backends/allo-v2.ts b/packages/common/src/allo/backends/allo-v2.ts index 1f9603081e..cbfefca2b8 100644 --- a/packages/common/src/allo/backends/allo-v2.ts +++ b/packages/common/src/allo/backends/allo-v2.ts @@ -1200,6 +1200,100 @@ export class AlloV2 implements Allo { return success(null); }); } + + addPoolManager(args: { poolId: string; manager: Address }): AlloOperation< + Result, + { + transaction: Result; + transactionStatus: Result; + indexingStatus: Result; + } + > { + 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, + { + transaction: Result; + transactionStatus: Result; + indexingStatus: Result; + } + > { + 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) { From 30c6698efe21197c7518fde5eef719d8b97458e3 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Tue, 14 May 2024 18:51:20 +0530 Subject: [PATCH 2/2] add fun to allo.ts --- packages/common/src/allo/allo.ts | 24 +++++++++++++++++ packages/common/src/allo/backends/allo-v1.ts | 28 ++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/packages/common/src/allo/allo.ts b/packages/common/src/allo/allo.ts index 28a5259407..46a0bcaaac 100644 --- a/packages/common/src/allo/allo.ts +++ b/packages/common/src/allo/allo.ts @@ -213,6 +213,30 @@ export interface Allo { indexingStatus: Result; } >; + + addPoolManager: (args: { + poolId: Hex; + manager: Address; + }) => AlloOperation< + Result, + { + transaction: Result; + transactionStatus: Result; + indexingStatus: Result; + } + >; + + removePoolManager: (args: { + poolId: Hex; + manager: Address; + }) => AlloOperation< + Result, + { + transaction: Result; + transactionStatus: Result; + indexingStatus: Result; + } + >; } export { AlloOperation }; diff --git a/packages/common/src/allo/backends/allo-v1.ts b/packages/common/src/allo/backends/allo-v1.ts index 74b51303d6..36b01e5000 100644 --- a/packages/common/src/allo/backends/allo-v1.ts +++ b/packages/common/src/allo/backends/allo-v1.ts @@ -1173,6 +1173,34 @@ export class AlloV1 implements Allo { return success(args.roundId); }); } + + addPoolManager(args: { poolId: string; manager: Address }): AlloOperation< + Result, + { + transaction: Result; + transactionStatus: Result; + indexingStatus: Result; + } + > { + return new AlloOperation(async ({ emit }) => { + const result = new AlloError("Unsupported on v1"); + return error(result); + }); + } + + removePoolManager(args: { poolId: string; manager: Address }): AlloOperation< + Result, + { + transaction: Result; + transactionStatus: Result; + indexingStatus: Result; + } + > { + return new AlloOperation(async ({ emit }) => { + const result = new AlloError("Unsupported on v1"); + return error(result); + }); + } } // todo: move this out?