Skip to content

Commit

Permalink
Better examples
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Sep 28, 2023
1 parent bb32a19 commit 23d85ec
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/js-client/src/internal/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import {
NumbersQueryParams,
PrepareInstallationParams,
} from "../types";
import { Networkish } from "@ethersproject/providers";
import {
DaoAction,
GasFeeEstimation,
PluginInstallItem,
PrepareInstallationStepValue,
} from "@aragon/sdk-client-common";
import { ProposeMemberStepValue } from "./types";

export interface IMyPluginClient {
methods: IMyPluginClientMethods;
Expand All @@ -22,13 +25,22 @@ export interface IMyPluginClientMethods {
params: PrepareInstallationParams,
): AsyncGenerator<PrepareInstallationStepValue>;
doSomething(): Promise<void>;
getNumber(daoAddressOrEns: string): Promise<bigint>;
getNumbers(params: NumbersQueryParams): Promise<NumberListItem[]>;
proposeMember(
memberAddress: string,
): AsyncGenerator<ProposeMemberStepValue>;
}
export interface IMyPluginClientEstimation {
prepareInstallation(
params: PrepareInstallationParams,
): Promise<GasFeeEstimation>;
}
export interface IMyPluginClientEncoding {
getPluginInstallItem(
params: PrepareInstallationParams,
network: Networkish,
): PluginInstallItem;
storeNumberAction(number: bigint): DaoAction;
}
export interface IMyPluginClientDecoding {
Expand Down
34 changes: 33 additions & 1 deletion packages/js-client/src/internal/modules/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import {
} from "../../../../contracts/typechain";
import { QueryNumber, QueryNumbers } from "../graphql-queries";
import { IMyPluginClientMethods } from "../interfaces";
import { SubgraphNumber, SubgraphNumberListItem } from "../types";
import {
ProposeMemberStep,
ProposeMemberStepValue,
SubgraphNumber,
SubgraphNumberListItem,
} from "../types";
import { toNumber, toNumberListItem } from "../utils";
import {
ClientCore,
Expand Down Expand Up @@ -132,4 +137,31 @@ export class MyPluginClientMethods extends ClientCore
}),
);
}

// implementation of the methods in the interface
public async *proposeMember(
memberAddress: string,
): AsyncGenerator<ProposeMemberStepValue> {
const signer = this.web3.getSigner();
const storageClient = MemberAccessPlugin__factory.connect(
this.spacePluginAddress,
signer,
);

// TODO: PIN metadata
const metadataUri = "ipfs://...";

const tx = await storageClient.proposeNewMember(metadataUri, memberAddress);

yield {
status: ProposeMemberStep.WAITING,
txHash: tx.hash,
};

await tx.wait();

yield {
status: ProposeMemberStep.DONE,
};
}
}
11 changes: 11 additions & 0 deletions packages/js-client/src/internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@ export type MyPluginOverriddenState =
& {
[key in keyof MyPluginContextState]: boolean;
};

export enum ProposeMemberStep {
WAITING = "waiting",
DONE = "done",
}
export type ProposeMemberStepValue = {
status: ProposeMemberStep.WAITING;
txHash: string;
} | {
status: ProposeMemberStep.DONE;
};

0 comments on commit 23d85ec

Please sign in to comment.