Skip to content

Commit

Permalink
chore: add/remove pool manager
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed May 13, 2024
1 parent ed72411 commit 070f424
Showing 1 changed file with 94 additions and 0 deletions.
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

0 comments on commit 070f424

Please sign in to comment.