Skip to content

Commit a7a168a

Browse files
committed
chore: add manageProfileMembers
1 parent 25a08b9 commit a7a168a

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

packages/common/src/allo/allo.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,19 @@ export interface Allo {
245245
}
246246
>;
247247

248+
manageProfileMembers: (args: {
249+
profileId: Hex;
250+
members: Address[];
251+
addOrRemove: "add" | "remove";
252+
}) => AlloOperation<
253+
Result<null>,
254+
{
255+
transaction: Result<Hex>;
256+
transactionStatus: Result<TransactionReceipt>;
257+
indexingStatus: Result<null>;
258+
}
259+
>;
260+
248261
directAllocation: (args: {
249262
tokenAddress: Address;
250263
poolId: string;

packages/common/src/allo/backends/allo-v1.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,25 @@ export class AlloV1 implements Allo {
13111311
});
13121312
}
13131313

1314+
manageProfileMembers(args: {
1315+
profileId: Hex;
1316+
members: Address[];
1317+
addOrRemove: "add" | "remove";
1318+
}): AlloOperation<
1319+
Result<null>,
1320+
{
1321+
transaction: Result<Hex>;
1322+
transactionStatus: Result<TransactionReceipt>;
1323+
indexingStatus: Result<null>;
1324+
}
1325+
> {
1326+
return new AlloOperation(async () => {
1327+
const result = new AlloError(`Unsupported on v1 ${args}`);
1328+
return error(result);
1329+
});
1330+
}
1331+
1332+
13141333
directAllocation(args: {
13151334
tokenAddress: Address;
13161335
poolId: string;

packages/common/src/allo/backends/allo-v2.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,64 @@ export class AlloV2 implements Allo {
15051505
});
15061506
}
15071507

1508+
manageProfileMembers(args: {
1509+
profileId: Hex;
1510+
members: Address[];
1511+
addOrRemove: "add" | "remove";
1512+
}): AlloOperation<
1513+
Result<null>,
1514+
{
1515+
transaction: Result<Hex>;
1516+
transactionStatus: Result<TransactionReceipt>;
1517+
indexingStatus: Result<null>;
1518+
}
1519+
> {
1520+
return new AlloOperation(async ({ emit }) => {
1521+
const txData =
1522+
args.addOrRemove === "add"
1523+
? this.registry.addMembers({
1524+
profileId: args.profileId,
1525+
members: args.members,
1526+
})
1527+
: this.registry.removeMembers({
1528+
profileId: args.profileId,
1529+
members: args.members,
1530+
});
1531+
1532+
const txResult = await sendRawTransaction(this.transactionSender, {
1533+
to: txData.to,
1534+
data: txData.data,
1535+
value: BigInt(txData.value),
1536+
});
1537+
1538+
emit("transaction", txResult);
1539+
1540+
if (txResult.type === "error") {
1541+
return error(txResult.error);
1542+
}
1543+
1544+
let receipt: TransactionReceipt;
1545+
try {
1546+
receipt = await this.transactionSender.wait(txResult.value);
1547+
emit("transactionStatus", success(receipt));
1548+
} catch (err) {
1549+
console.log(err);
1550+
const result = new AlloError(`Failed to ${args.addOrRemove} profile members`);
1551+
emit("transactionStatus", error(result));
1552+
return error(result);
1553+
}
1554+
1555+
await this.waitUntilIndexerSynced({
1556+
chainId: this.chainId,
1557+
blockNumber: receipt.blockNumber,
1558+
});
1559+
1560+
emit("indexingStatus", success(null));
1561+
1562+
return success(null);
1563+
});
1564+
}
1565+
15081566
directAllocation(args: {
15091567
tokenAddress: Address;
15101568
poolId: string;

0 commit comments

Comments
 (0)