Skip to content

Commit

Permalink
Merge branch 'develop' into fix/various-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
heueristik authored Nov 20, 2023
2 parents 751e30e + 7cd47bd commit 9f03c34
Show file tree
Hide file tree
Showing 32 changed files with 585 additions and 33 deletions.
6 changes: 6 additions & 0 deletions modules/client-common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ TEMPLATE:
-->

## [UPCOMING]

### Added

- Added `actions` to `SubgraphListItem` type

## [1.10.0]
### Added

- Add support for arbitrum network
Expand Down
2 changes: 1 addition & 1 deletion modules/client-common/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@aragon/sdk-client-common",
"author": "Aragon Association",
"version": "1.10.0",
"version": "1.11.0",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/sdk-client-common.esm.js",
Expand Down
6 changes: 6 additions & 0 deletions modules/client-common/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,9 @@ export const ApplyUninstallationSchema = object({
export const ApplyInstallationSchema = ApplyUninstallationSchema.concat(object({
helpers: array(AddressOrEnsSchema).required(),
}));

export const IsMemberSchema = object({
address: AddressOrEnsSchema.required(),
pluginAddress: AddressOrEnsSchema.required(),
blockNumber: number().notRequired(),
});
6 changes: 6 additions & 0 deletions modules/client-common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export type ProposalListItemBase = {
startDate: Date;
endDate: Date;
status: ProposalStatus;
actions: DaoAction[];
};

export type PrepareUpdateParams = {
Expand Down Expand Up @@ -278,3 +279,8 @@ export enum SupportedVersion {
V1_3_0 = "1.3.0",
LATEST = "1.3.0",
}
export type IsMemberParams = {
address: string;
pluginAddress: string;
blockNumber?: number;
};
11 changes: 11 additions & 0 deletions modules/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ TEMPLATE:
-->

## [UPCOMING]

### Added

- `isMember` function to `TokenVotingClient`
- `isMember` function to `AddresslistVotingClient`
- `isMember` function to `Client`
- Add `actions` to `MultisigProposalListItem`
- Add `actions` to `TokenVotingProposalListItem`
- Add `actions` to `AddresslistVotingProposalListItem`

## [1.18.2]
### Fixed

- Plugin preparations query
Expand Down
31 changes: 31 additions & 0 deletions modules/client/examples/02-multisig-client/15-is-member.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* MARKDOWN
---
title: Is Member
---
### Check if an address is a member of Multisig DAO in a specific block and plugin
The is member function receives the plugin address and the address to check as parameters and returns a boolean value.
*/

import { MultisigClient } from "@aragon/sdk-client";
import { context } from "../index";

// Instantiate the multisig client from the Aragon OSx SDK context.
const client: MultisigClient = new MultisigClient(context);

const isMember = await client.methods.isMember({
pluginAddress: "0x2345678901234567890123456789012345678901",
address: "0x1234567890123456789012345678901234567890",
blockNumber: 12345678,
});

console.log(isMember);

/* MARKDOWN
Returns:
```tsx
true
```
*/
31 changes: 31 additions & 0 deletions modules/client/examples/03-tokenVoting-client/22-is-member.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* MARKDOWN
---
title: Is Member
---
### Check if an address is a member of TokenVoting DAO in a specific block and plugin
The is member function receives the plugin address and the address to check as parameters and returns a boolean value.
*/

import { TokenVotingClient } from "@aragon/sdk-client";
import { context } from "../index";

// Instantiate the token voting client from the Aragon OSx SDK context.
const client: TokenVotingClient = new TokenVotingClient(context);

const isMember = await client.methods.isMember({
pluginAddress: "0x2345678901234567890123456789012345678901",
address: "0x1234567890123456789012345678901234567890",
blockNumber: 12345678,
});

console.log(isMember);

/* MARKDOWN
Returns:
```tsx
true
```
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* MARKDOWN
---
title: Is Member
---
### Check if an address is a member of an Addresslist DAO in a specific block and plugin
The is member function receives the plugin address and the address to check as parameters and returns a boolean value.
*/

import { AddresslistVotingClient } from "@aragon/sdk-client";
import { context } from "../index";

// Instantiate the addresslist voting client from the Aragon OSx SDK context.
const client: AddresslistVotingClient = new AddresslistVotingClient(context);

const isMember = await client.methods.isMember({
pluginAddress: "0x2345678901234567890123456789012345678901",
address: "0x1234567890123456789012345678901234567890",
blockNumber: 12345678,
});

console.log(isMember);

/* MARKDOWN
Returns:
```tsx
true
```
*/
4 changes: 2 additions & 2 deletions modules/client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@aragon/sdk-client",
"author": "Aragon Association",
"version": "1.18.2",
"version": "1.19.0",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/sdk-client.esm.js",
Expand Down Expand Up @@ -62,7 +62,7 @@
},
"dependencies": {
"@aragon/osx-ethers": "1.3.0-rc0.4",
"@aragon/sdk-client-common": "^1.10.0",
"@aragon/sdk-client-common": "^1.11.0",
"@aragon/sdk-ipfs": "^1.1.0",
"@ethersproject/abstract-signer": "^5.5.0",
"@ethersproject/bignumber": "^5.6.0",
Expand Down
28 changes: 28 additions & 0 deletions modules/client/src/addresslistVoting/internal/client/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
votingSettingsToContract,
} from "../../../client-common";
import {
QueryAddresslistVotingIsMember,
QueryAddresslistVotingMembers,
QueryAddresslistVotingProposal,
QueryAddresslistVotingProposals,
Expand Down Expand Up @@ -55,6 +56,8 @@ import {
InvalidCidError,
InvalidProposalIdError,
IpfsPinError,
IsMemberParams,
IsMemberSchema,
isProposalId,
MULTI_FETCH_TIMEOUT,
NoProviderError,
Expand Down Expand Up @@ -578,4 +581,29 @@ export class AddresslistVotingClientMethods extends ClientCore
votingMode: addresslistVotingPlugin.votingMode,
};
}

/**
* Checks if a given address is a member of the AddresslistVoting contract.
* @param params - The parameters for the isMember method.
* @param params.pluginAddress - The address of the plugin.
* @param params.address - The address to check.
* @param params.blockNumber - The block number for specifying a specific block.
* @returns A boolean indicating whether the address is a member or not.
*/
public async isMember(params: IsMemberParams): Promise<boolean> {
IsMemberSchema.strict().validateSync(params);
const query = QueryAddresslistVotingIsMember;
const name = "AddresslistVoting isMember";
type T = { addresslistVotingVoter: { id: string } };
const { addresslistVotingVoter } = await this.graphql.request<T>({
query,
params: {
id:
`${params.pluginAddress.toLowerCase()}_${params.address.toLowerCase()}`,
blockHeight: params.blockNumber ? { number: params.blockNumber } : null,
},
name,
});
return !!addresslistVotingVoter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ query AddresslistVotingMembers($where: AddresslistVotingVoter_filter!, $block: B
address
}
}`;

export const QueryAddresslistVotingIsMember = gql`
query AddresslistVotingIsMember($id: ID!, $block: Block_height) {
addresslistVotingVoter(
id: $id
block: $block
) {
id
}
}`;
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ query AddresslistVotingProposals($where: AddresslistVotingProposal_filter!, $lim
id
subdomain
}
actions {
to
value
data
}
creator
metadata
yes
Expand Down
2 changes: 2 additions & 0 deletions modules/client/src/addresslistVoting/internal/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DaoAction,
GasFeeEstimation,
InterfaceParams,
IsMemberParams,
PrepareInstallationStepValue,
PrepareUpdateStepValue,
ProposalMetadata,
Expand Down Expand Up @@ -57,6 +58,7 @@ export interface IAddresslistVotingClientMethods {
pluginAddress: string,
blockNumber?: number,
) => Promise<VotingSettings | null>;
isMember: (params: IsMemberParams) => Promise<boolean>;
}

export interface IAddresslistVotingClientEncoding {
Expand Down
2 changes: 0 additions & 2 deletions modules/client/src/addresslistVoting/internal/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
ContractVotingSettings,
SubgraphAction,
SubgraphProposalBase,
SubgraphVoterListItemBase,
VotingMode,
Expand All @@ -22,7 +21,6 @@ export type SubgraphAddresslistVotingProposalListItem = SubgraphProposalBase & {

export type SubgraphAddresslistVotingProposal = SubgraphProposalBase & {
createdAt: string;
actions: SubgraphAction[];
supportThreshold: string;
minVotingPower: string;
voters: SubgraphAddresslistVotingVoterListItem[];
Expand Down
9 changes: 9 additions & 0 deletions modules/client/src/addresslistVoting/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ export function toAddresslistVotingProposalListItem(
no: proposal.no ? parseInt(proposal.no) : 0,
abstain: proposal.abstain ? parseInt(proposal.abstain) : 0,
},
actions: proposal.actions.map(
(action: SubgraphAction): DaoAction => {
return {
data: hexToBytes(action.data),
to: action.to,
value: BigInt(action.value),
};
},
),
votes: proposal.voters.map(
(voter: SubgraphAddresslistVotingVoterListItem) => {
return {
Expand Down
1 change: 1 addition & 0 deletions modules/client/src/client-common/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export type SubgraphProposalBase = {
endDate: string;
executed: boolean;
potentiallyExecutable: boolean;
actions: SubgraphAction[]
};

export type ProposalQueryParams = Pagination & {
Expand Down
30 changes: 29 additions & 1 deletion modules/client/src/multisig/internal/client/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from "../../../client-common";
import { Multisig__factory } from "@aragon/osx-ethers";
import {
QueryMultisigIsMember,
QueryMultisigMembers,
QueryMultisigProposal,
QueryMultisigProposals,
Expand All @@ -53,6 +54,8 @@ import {
InvalidCidError,
InvalidProposalIdError,
IpfsPinError,
IsMemberParams,
IsMemberSchema,
isProposalId,
MULTI_FETCH_TIMEOUT,
NoProviderError,
Expand Down Expand Up @@ -389,7 +392,7 @@ export class MultisigClientMethods extends ClientCore
skip = 0,
direction = SortDirection.ASC,
sortBy = MembersSortBy.ADDRESS,
}: MembersQueryParams): Promise<string[]>{
}: MembersQueryParams): Promise<string[]> {
// TODO
// update this with yup validation
if (!isAddress(pluginAddress)) {
Expand Down Expand Up @@ -565,4 +568,29 @@ export class MultisigClientMethods extends ClientCore
),
);
}

/**
* Checks if a given address is a member of the tokenVoting contract.
* @param params - The parameters for the isMember method.
* @param params.pluginAddress - The address of the plugin.
* @param params.address - The address to check.
* @param params.blockNumber - The block number for specifying a specific block.
* @returns A boolean indicating whether the address is a member or not.
*/
public async isMember(params: IsMemberParams): Promise<boolean> {
IsMemberSchema.strict().validateSync(params);
const query = QueryMultisigIsMember;
const name = "multisig isMember";
type T = { multisigApprover: { id: string } };
const { multisigApprover } = await this.graphql.request<T>({
query,
params: {
id:
`${params.pluginAddress.toLowerCase()}_${params.address.toLowerCase()}`,
blockHeight: params.blockNumber ? { number: params.blockNumber } : null,
},
name,
});
return !!multisigApprover;
}
}
10 changes: 10 additions & 0 deletions modules/client/src/multisig/internal/graphql-queries/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ query MultisigMembers($where: MultisigApprover_filter!, $block: Block_height, $l
}
}
`;

export const QueryMultisigIsMember = gql`
query MultisigIsMember($id: ID!, $block: Block_height) {
multisigApprover(
id: $id
block: $block
) {
id
}
}`;
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ query MultisigProposals($where: MultisigProposal_filter!, $limit:Int!, $skip: In
approvers {
id
}
actions {
to
value
data
}
minApprovals
plugin{
onlyListed
Expand Down
Loading

0 comments on commit 9f03c34

Please sign in to comment.