Skip to content

Commit fc470c1

Browse files
committed
feat(justifications): support multiple vote IDs
1 parent 9f6ac82 commit fc470c1

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/court/justifications.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports.put = async (event, _context, callback) => {
4040
}
4141

4242
// Verify votes belong to user
43-
for (const voteID of payload.justification.IDs) {
43+
for (const voteID of payload.justification.voteIDs) {
4444
const vote = await klerosLiquid.methods
4545
.getVote(
4646
payload.justification.disputeID,
@@ -62,9 +62,16 @@ module.exports.put = async (event, _context, callback) => {
6262
// Save justification
6363
await dynamoDB.putItem({
6464
Item: {
65-
disputeID: { N: String(payload.justification.disputeID) },
66-
appeal: { N: String(payload.justification.appeal) },
67-
IDs: { NS: payload.justification.IDs },
65+
disputeIDAndAppeal: {
66+
S: `${payload.justification.disputeID}-${payload.justification.appeal}`
67+
},
68+
voteID: {
69+
N: String(
70+
payload.justification.voteIDs[
71+
payload.justification.voteIDs.length - 1
72+
]
73+
)
74+
},
6875
justification: { S: payload.justification.justification }
6976
},
7077
TableName: 'justifications'

src/court/models/justifications.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"type": "number",
2222
"description": "The appeal of the dispute the votes are cast for."
2323
},
24-
"IDs": {
24+
"voteIDs": {
2525
"type": "array",
2626
"items": {
2727
"type": "number"
@@ -59,7 +59,7 @@
5959
"type": "number",
6060
"description": "The appeal of the dispute the votes are cast for."
6161
},
62-
"IDs": {
62+
"voteIDs": {
6363
"type": "array",
6464
"items": {
6565
"type": "number"

0 commit comments

Comments
 (0)