-
Notifications
You must be signed in to change notification settings - Fork 14
feat(APP-667): Pull token voting ERC20 members from aragon-subdomain #1128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
asciiman
wants to merge
38
commits into
main
Choose a base branch
from
app-667-pull-token-voting-erc20-members-from-aragon-subdomain
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
1209f32
Pull token voting erc20 members from aragon-subdomain
asciiman 4151be8
Now route all mainnet tokenvoting erc20 member from subdomain
asciiman 9b6e471
Only route erc20 token voting plugins to subdomain
asciiman 264202c
Remove ENS_SUBGRAPH_URL dependency from member route
asciiman 7cfcaa8
Use published aragon-subdomain
asciiman 2a4e536
Merge branch 'main' into app-667-pull-token-voting-erc20-members-from…
asciiman 0929ffe
Merge branch 'main' into app-667-pull-token-voting-erc20-members-from…
asciiman 689ff7f
Update the subdomain lib
asciiman 5d98bbc
Use aragon-domain types for token voting
asciiman 5ae37b6
Change package from aragon-subdomain to aragon-domain
asciiman a75e70f
Fix import
asciiman 4d44edf
Fix mapper
asciiman 9c8d7be
Add api key
asciiman a992adf
Update domain
asciiman 802e3b3
Merge branch 'main' into app-667-pull-token-voting-erc20-members-from…
asciiman 8055750
Merge branch 'main' into app-667-pull-token-voting-erc20-members-from…
asciiman ffb23b4
refactor(APP-667): re-home token-voting membership onto the aragonDom…
asciiman d5a58e9
chore(APP-667): bump aragon-domain to snapshot 0.0.0-20260730113648
asciiman 5ec39fd
docs(APP-667): clarify the defensive token reads in buildTokenVotingM…
asciiman 956e937
refactor(APP-667): require token-carrying settings in buildTokenVotin…
asciiman 47cb89b
refactor(APP-667): rename isTokenVotingMembershipPlugin to isTokenMem…
asciiman 31d4c18
Clean up comments
asciiman 887f568
Fix server code being pulled into client
asciiman 8531f72
Make linked account check server safe
asciiman cd6116f
Return domain from service
asciiman 8bd171f
Resolve activity for member details
asciiman 7c46cf4
Simplified code
asciiman b08e192
Docs
asciiman c301684
Rename hook
asciiman 4ae75d8
Validate query params
asciiman 5990ac9
Convert activity correctly
asciiman 847bb3c
Update map
asciiman 4ad218e
Docs
asciiman bd64317
Clean up comment
asciiman 700c456
Merge branch 'main' into app-667-pull-token-voting-erc20-members-from…
asciiman d7da02e
Change domain timestamp handling
asciiman b5b6da6
Merge remote-tracking branch 'origin/main' into app-667-pull-token-vo…
tyhonchik 8269bb7
feat(APP-667): gate the aragon-domain member source behind a flag and…
tyhonchik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
.changeset/app-667-token-voting-members-from-aragon-domain.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@aragon/app": minor | ||
| --- | ||
|
|
||
| Serve mainnet ERC-20 token-voting member lists from the aragon-domain (Envio) BFF, with source routing and a legacy-backend fallback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
apps/app/src/app/api/domain/token-voting/members/route.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /** @jest-environment node */ | ||
|
|
||
| import type { NextRequest } from 'next/server'; | ||
| import { tokenVotingMembershipServiceServer } from '@/modules/governance/api/tokenVotingMembershipService/tokenVotingMembershipService.server'; | ||
| import { GET } from './route'; | ||
|
|
||
| const pluginAddress = '0x1111111111111111111111111111111111111111'; | ||
| const tokenContractAddress = '0x2222222222222222222222222222222222222222'; | ||
|
|
||
| const generateRequest = (query: string): NextRequest => | ||
| ({ | ||
| nextUrl: new URL( | ||
| `http://localhost/api/domain/token-voting/members?${query}`, | ||
| ), | ||
| }) as NextRequest; | ||
|
|
||
| describe('GET /api/domain/token-voting/members', () => { | ||
| const getMembershipSpy = jest.spyOn( | ||
| tokenVotingMembershipServiceServer, | ||
| 'getTokenVotingMembership', | ||
| ); | ||
|
|
||
| afterEach(() => { | ||
| getMembershipSpy.mockReset(); | ||
| }); | ||
|
|
||
| it.each([ | ||
| [ | ||
| 'a missing plugin address', | ||
| `tokenContractAddress=${tokenContractAddress}`, | ||
| ], | ||
| [ | ||
| 'an invalid plugin address', | ||
| `pluginAddress=not-an-address&tokenContractAddress=${tokenContractAddress}`, | ||
| ], | ||
| [ | ||
| 'an invalid token contract address', | ||
| `pluginAddress=${pluginAddress}&tokenContractAddress=0x1234`, | ||
| ], | ||
| [ | ||
| 'a non-integer page', | ||
| `pluginAddress=${pluginAddress}&tokenContractAddress=${tokenContractAddress}&page=first`, | ||
| ], | ||
| [ | ||
| 'a non-positive page size', | ||
| `pluginAddress=${pluginAddress}&tokenContractAddress=${tokenContractAddress}&pageSize=0`, | ||
| ], | ||
| [ | ||
| 'a page size above the domain maximum', | ||
| `pluginAddress=${pluginAddress}&tokenContractAddress=${tokenContractAddress}&pageSize=251`, | ||
| ], | ||
| ])('returns 400 for %s', async (_label, query) => { | ||
| const response = await GET(generateRequest(query)); | ||
|
|
||
| expect(response.status).toBe(400); | ||
| expect(getMembershipSpy).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('passes validated request parameters to the domain service', async () => { | ||
| const result = { | ||
| data: [], | ||
| metadata: { page: 2, pageSize: 25, totalPages: 0, totalRecords: 0 }, | ||
| }; | ||
| getMembershipSpy.mockResolvedValue(result); | ||
|
|
||
| const response = await GET( | ||
| generateRequest( | ||
| `pluginAddress=${pluginAddress}&tokenContractAddress=${tokenContractAddress}&page=2&pageSize=25`, | ||
| ), | ||
| ); | ||
|
|
||
| expect(response.status).toBe(200); | ||
| expect(getMembershipSpy).toHaveBeenCalledWith({ | ||
| queryParams: { | ||
| pluginAddress, | ||
| tokenContractAddress, | ||
| page: 2, | ||
| pageSize: 25, | ||
| }, | ||
| }); | ||
| await expect(response.json()).resolves.toEqual(result); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import { type NextRequest, NextResponse } from 'next/server'; | ||
| // biome-ignore lint/style/noRestrictedImports: server-only BFF validation; strict EIP-55 validation is explicitly disabled. | ||
| import { isAddress } from 'viem'; | ||
| import { tokenVotingMembershipServiceServer } from '@/modules/governance/api/tokenVotingMembershipService/tokenVotingMembershipService.server'; | ||
| import { monitoringUtils } from '@/shared/utils/monitoringUtils'; | ||
|
|
||
| const maximumPageSize = 250; | ||
|
|
||
| interface ITokenVotingMembershipQueryParams { | ||
| pluginAddress: string; | ||
| tokenContractAddress: string; | ||
| page?: number; | ||
| pageSize?: number; | ||
| } | ||
|
|
||
| const validateQueryParams = ( | ||
| params: URLSearchParams, | ||
| ): ITokenVotingMembershipQueryParams | undefined => { | ||
| const pluginAddress = params.get('pluginAddress'); | ||
| const tokenContractAddress = params.get('tokenContractAddress'); | ||
| const page = params.get('page'); | ||
| const pageSize = params.get('pageSize'); | ||
| const parsedPage = page != null ? Number(page) : undefined; | ||
| const parsedPageSize = pageSize != null ? Number(pageSize) : undefined; | ||
|
|
||
| if ( | ||
| pluginAddress == null || | ||
| tokenContractAddress == null || | ||
| !isAddress(pluginAddress, { strict: false }) || | ||
| !isAddress(tokenContractAddress, { strict: false }) || | ||
| (parsedPage != null && | ||
| (!Number.isInteger(parsedPage) || parsedPage <= 0)) || | ||
| (parsedPageSize != null && | ||
| (!Number.isInteger(parsedPageSize) || | ||
| parsedPageSize <= 0 || | ||
| parsedPageSize > maximumPageSize)) | ||
| ) { | ||
| return; | ||
| } | ||
|
|
||
| return { | ||
| pluginAddress, | ||
| tokenContractAddress, | ||
| page: parsedPage, | ||
| pageSize: parsedPageSize, | ||
| }; | ||
| }; | ||
|
|
||
| export const GET = async (req: NextRequest) => { | ||
| const queryParams = validateQueryParams(req.nextUrl.searchParams); | ||
|
|
||
| if (queryParams == null) { | ||
| return NextResponse.json( | ||
| { | ||
| error: 'pluginAddress and tokenContractAddress must be valid addresses; page must be a positive integer; pageSize must be a positive integer no greater than 250', | ||
| }, | ||
| { status: 400 }, | ||
| ); | ||
| } | ||
|
|
||
| try { | ||
| const result = | ||
| await tokenVotingMembershipServiceServer.getTokenVotingMembership({ | ||
| queryParams, | ||
| }); | ||
|
|
||
| return NextResponse.json(result); | ||
| } catch (error) { | ||
| monitoringUtils.logError(error, { | ||
| context: { | ||
| errorType: 'get_token_voting_membership_error', | ||
| pluginAddress: queryParams.pluginAddress, | ||
| tokenContractAddress: queryParams.tokenContractAddress, | ||
| }, | ||
| }); | ||
|
|
||
| return NextResponse.json( | ||
| { error: 'getTokenVotingMembership request failed' }, | ||
| { status: 500 }, | ||
| ); | ||
| } | ||
| }; | ||
4 changes: 3 additions & 1 deletion
4
apps/app/src/app/dao/[network]/[addressOrEns]/(daoPage)/members/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| import { DaoMembersPage } from '@/modules/governance/pages/daoMembersPage'; | ||
| // Imported from the page file (not the module barrel): the RSC pulls in | ||
| // server-only prefetch code that must stay out of the barrel's client graph. | ||
| import { DaoMembersPage } from '@/modules/governance/pages/daoMembersPage/daoMembersPage'; | ||
|
|
||
| export default DaoMembersPage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no network param anywhere in this chain (route → server service → domain), and the domain query isn't chain-scoped either (raised on aragon/aragon-domain#4) — the same token address on two chains would mix members. once the domain takes a chainId, this request shape needs it too; maybe worth adding the param now to avoid a second API change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
route takes
chainIdnow (required, positive int), the routing layer maps the dao network to it, and the domain request DTO carries it (aragon/aragon-domain#4).