Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

improve membersURI#812

Open
Rashmi-278 wants to merge 28 commits into
snapshot-labs:masterfrom
metagov:improve-membersURI
Open

improve membersURI#812
Rashmi-278 wants to merge 28 commits into
snapshot-labs:masterfrom
metagov:improve-membersURI

Conversation

@Rashmi-278

@Rashmi-278 Rashmi-278 commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

Fixes #825

Changes proposed in this pull request:

  • Get unique Voters for a Space
  • Import getCombinedMembersAndVoters function in EIP4824 File
  • Include Unique Voters in the members list for a space
  • Change "@context": "http://www.daostar.org/schemas", everywhere to "@context": ["https://www.snapshot.org", https://www.daostar.org/schemas"],

Comment thread src/helpers/spaces.ts
Comment thread src/eip4824.ts Outdated
Comment thread src/eip4824.ts Outdated
@Rashmi-278
Rashmi-278 requested a review from bonustrack April 22, 2024 14:01
bonustrack
bonustrack approved these changes Apr 29, 2024

@bonustrack bonustrack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll review this PR, don't merge yet

Comment thread .gitignore Outdated
Comment thread src/eip4824.ts Outdated
Comment thread src/eip4824.ts Outdated
@bonustrack
bonustrack requested a review from ChaituVR May 1, 2024 13:32
Rashmi-278 and others added 5 commits May 1, 2024 19:33
Co-authored-by: Less <bonustrack@users.noreply.github.com>
Co-authored-by: Less <bonustrack@users.noreply.github.com>
@Rashmi-278
Rashmi-278 requested a review from bonustrack May 1, 2024 14:17
Comment thread pnpm-lock.yaml Outdated
@Rashmi-278
Rashmi-278 requested a review from bonustrack May 2, 2024 03:51
Comment thread src/helpers/spaces.ts Outdated
Comment thread src/helpers/spaces.ts Outdated
Comment on lines +169 to +171
(SELECT DISTINCT voter AS address
FROM votes
WHERE space = ?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should limit to 500 voters

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have placed the limit to the Outer Query, using the param, pageSize.
Placing a limit on the inner query would mess up the pagination, wouldn't it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but this is taking a lot of time, especially for spaces with a lot of votes, we don't need to read all the distinct voters here, we just need 500 of them,

you can remove pagination from the outer query

Also for admins, moderators and members -> all this data is already available on space object, we don't need to read them from database again,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We made an improvement on this, now the with cursor filter, if cursor is present, admins, moderators, and members are excluded from the distinct voter list. Also regardless we are not querying admins, moderators and members.

Query now only queries the Votes Table hence eliminating the need for subqueries.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how to use cursor now? you have an example request? i tried few ways but couldn't get it working

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A request should be something like /ens.eth/members?cursor=983434323 ( Cursor Example )

Could you share what message do you get?
Could we get on a call and debug this? As I don't have a way to see whats wrong, its taking longer to close this issue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we have to pass address to cursor now, something like http://localhost:3000/api/eip4824/ens.eth/members?cursor=0xB8cb5Bbf2DdD552145336436b2A0FD490aBf88Ca works

Comment thread src/eip4824.ts
@ChaituVR

ChaituVR commented May 2, 2024

Copy link
Copy Markdown
Member

Apart from above comments, everything looks to be working nicely 👍

Comment thread src/helpers/spaces.ts Outdated
Comment thread src/helpers/spaces.ts Outdated
Comment thread src/eip4824.ts Outdated
Comment thread src/eip4824.ts Outdated
@ChaituVR
ChaituVR self-requested a review July 10, 2024 05:02
Comment thread src/eip4824.ts Outdated

@ChaituVR ChaituVR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tAck

@ChaituVR

Copy link
Copy Markdown
Member

@bonustrack Looks like we need your approval

Untitled 2

Comment thread src/helpers/spaces.ts Outdated
let exclusionClause = '';
if (exclusionList.length > 0) {
const placeholders = exclusionList.map(() => '?').join(', ');
exclusionClause = `AND voter NOT IN (${placeholders})`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be used to inject arbitrary SQL? I think placeholders should be added as params so it get parsed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that would be of concern here because

  1. Placeholders values are not user input values
  2. Placeholder values are either empty lists or space.admins, space.moderators, space.members
  3. params.push(...exclusionList) This pushes the actual exclusion list values (the voters you want to exclude) into the params array, which is passed to the query execution.
  4. const results =await db.queryAsync(query, params); The database library takes care of escaping the values in params, preventing SQL injection.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values (admins, moderators, members) are actually inputs from space admin, even if we have a strict format, I would prefer if that query doesn't depend on validation of such user input. And exclusionList is parsed but not exclusionClause. If you can update that we can move forward with your PR.

@Rashmi-278
Rashmi-278 requested a review from bonustrack February 5, 2025 12:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrading Snapshot's EIP4824 daoURI implementation

3 participants