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) {