-
Notifications
You must be signed in to change notification settings - Fork 6
Offchain votes choices #1803
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
Offchain votes choices #1803
Changes from all commits
ac8460e
d97a8ac
38f993e
89fdeef
a824095
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,12 +44,13 @@ export const OffchainVoteChoiceSchema = z | |
| z | ||
| .number() | ||
| .int() | ||
| .transform((val) => [val]), | ||
| z.array(z.number().int()), | ||
| .transform((val) => [val.toString()]), | ||
| z.array(z.string()), | ||
| z.record(z.string(), z.number()).transform((val) => Object.keys(val)), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Snapshot stores a vote choice as an object (e.g. approval/weighted formats like Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Mapping object-form choices with Useful? React with 👍 / 👎. |
||
| ]) | ||
| .openapi("SnapshotVoteChoice", { | ||
| type: "array", | ||
| items: { type: "integer", nullable: false }, | ||
| items: { type: "string", nullable: false }, | ||
| }); | ||
|
|
||
| export const OffchainVoteResponseSchema = z | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| query GetOffchainVotesByProposalId( | ||
| $id: String! | ||
| $fromDate: Int | ||
| $limit: Int | ||
| $orderBy: queryInput_votesOffchainByProposalId_orderBy = timestamp | ||
| $orderDirection: OrderDirection = asc | ||
| $skip: Int | ||
| $toDate: Int | ||
| $voterAddresses: [String] | ||
| ) { | ||
| votesOffchainByProposalId( | ||
| fromDate: $fromDate | ||
| limit: $limit | ||
| orderBy: $orderBy | ||
| orderDirection: $orderDirection | ||
| toDate: $toDate | ||
| voterAddresses: $voterAddresses | ||
| id: $id | ||
| skip: $skip | ||
| ) { | ||
| totalCount | ||
| items { | ||
| choice | ||
| created | ||
| proposalId | ||
| proposalTitle | ||
| reason | ||
| voter | ||
| vp | ||
| } | ||
| } | ||
| } |
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.
This schema now only accepts
z.array(z.string())for array-form choices, but Snapshot approval/ranked-choice votes are commonly stored as numeric arrays (e.g.[1, 2]). Those rows will failOffchainVotesResponseSchema.parse(...)and make/offchain/votesand/offchain/proposals/{id}/votesreturn 500 whenever such votes are present. Keep supporting numeric arrays (or transform them) to preserve compatibility with existing offchain vote data.Useful? React with 👍 / 👎.