Skip to content

Seed for TAZ #114

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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,319 changes: 1,215 additions & 104 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@ethersproject/keccak256": "^5.7.0",
"@ethersproject/strings": "^5.7.0",
"@faker-js/faker": "^8.0.2",
"@pcd/zk-eddsa-event-ticket-pcd": "^0.2.1",
"@prisma/client": "^5.5.2",
"@semaphore-protocol/identity": "^3.15.0",
"@socket.io/admin-ui": "^0.5.1",
Expand All @@ -41,6 +42,7 @@
"express": "^4.18.2",
"express-basic-auth": "^1.2.1",
"express-rate-limit": "^7.1.1",
"express-session": "^1.17.3",
"ffjavascript": "^0.2.60",
"helmet": "^7.0.0",
"idc-nullifier": "^0.0.7",
Expand All @@ -49,7 +51,8 @@
"rlnjs": "^3.2.0",
"snarkjs": "^0.7.1",
"socket.io": "^4.6.2",
"uuidv4": "^6.2.13"
"uuidv4": "^6.2.13",
"zuauth": "^0.4.0"
},
"devDependencies": {
"@jest/globals": "^29.6.2",
Expand Down
102 changes: 102 additions & 0 deletions prisma/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2983,6 +2983,108 @@ const addresses = {
'0x954a86c613fd1fbac9c7a43a071a68254c75e4ac',
'0xc50c8679938868112b933c254bbdd44a837e6f85',
'0x1baec9d58603f6eaeddbd66acc56db76215fc8d6'
],
taz: [
"5581662991965116907536216475717741984198089402102305891665622779337909307244",
"5092281831438693052529781398117657504475257624068853514849165729274317202844",
"393517112895218716844900051692789615194349093744517441535910011721512544992",
"13495502136805771693867089484513912857635483399068027905672757967301996204325",
"14305472661953206523835615203374334527414017917403013755110623375434453212867",
"16204708241458039628252037843043559163462395082292087780140177936367262535723",
"14750625699982191191518101285620315258426602817274665460026148605711526851761",
"20128228197203667389097037608725907347668538927209808365900012479787680550110",
"12649845922245283902842720868068756187303261996739305829396124486818410607421",
"17384667470002213692070659087097981403755723027303429008335901118045519262588",
"15655857540673602671546560042743459434063772522831554785347422853399787564713",
"2876730219971679973198627930365325904679107876200174706784024458478320446383",
"18484321466159115974911048117709102215593531323615336527199785184780578400619",
"16089703034499675272097698507294741751691549168765213890164542688577372859425",
"16423854500547593760308145942854740142789817416261100274905446114740033410590",
"918717042546514963252045575545867666201310520987914594186007064723786606950",
"7217767815580485173287994191945484182189487433007749052125489637868652152455",
"3510191046476870976026959499568310325496360708487982473006287749996077291413",
"21708563094266004595823752507046487078437057252714804658124605225715953053077",
"14993424366273629491547740634290577811783852524411120487858788662525209565524",
"12133488620502866422328577066722572948540348162602693549191699769513913773425",
"15754581923244004881690496666193798487765240552002037477670212869682983198191",
"1822671220355560114799118939099953828542980176421912605664430763321308782870",
"21683321230652606385409597835570842049567483787766876348786026498110161669018",
"15811583454315079346810431507939524523788414999988788374585371585806349653358",
"18405458439126286420846861338437431633563603369484527576602063234565964530751",
"4403216110985822155163073001566309570062974493350312621489440372295273059255",
"13059299728790545552984869461786101393147821798389298596896696948794505925120",
"1744538741025072907768127786235966970882174879080838400002260161037918272636",
"4943151252229807710565270121883744098265930825001375800460594371929896274847",
"12450890054640890536720619576229580022485523889438647074783024665603861125022",
"17956316133674296273086633123721246821767272307058876897804976264930673920105",
"6981829173355728010866179583264113651715295124945734317378277209756039291213",
"21092437562747712070841486288082127438363069138221480476245638987202915680790",
"13792056395444821774087634838093886009194819117360823217337630796664062243485",
"13727542542292048043158269965326666108333972089531101433256373915340054274557",
"9413158174073053463381201723697621705435837846394146134613635975604885826433",
"21834555350063534477364615284866681874452872920986365441578886407327972601147",
"20979768001375542654811941336869282738423631295635152358050406538092664636480",
"3688185233646248175512409320452116798464469326991473726001109330671330950187",
"12052633777491027749579571366585184237931131990458793025668178945797425333671",
"3749433975017284265447130365295325630979031368388247176314191807415840292296",
"3352646161795814902921907141766673148954160429904377235198522253816841531764",
"4716408706324694483229263619523886095491040481780737248468059865265477221692",
"8846147216128560371955500952679823820132817264813605968878988379876322695499",
"11693926812124777004991556454598103083238171014741807835275367736228314697663",
"10097992538655895022791751012908446897675015141867951349462944301128203116789",
"10143697040759735775580504193524675508418499713666866763381458024077545936916",
"5551082806627428918580344244614152638613139410487021682043358613540102507423",
"1264564686315173037562151354441462034908120374393143133011140813866031358888",
"4227836741516566528015145492797650150717020607534198831812362200265073479415",
"4327405086306165815754878241293795825160488241649394918398298319263824896000",
"3519306709712377126771366300013284089987120408756894314290813967670628485048",
"15741660173399262271133553558244903212994941452351979490674780227586299787176",
"20136215608904908320771399921910190610149012894403516082770743807608560944125",
"1661547774391410805895293358144202073541302464481773585874832583303039427631",
"12885441794945081240652467737825577312066469289252367275278129036331746534800",
"861258679271839409428979536294418969023875553925731284099086416861389896282",
"13872869364536982456919357216794879502220860771913830246478850541706921312918",
"1047584877163629479752164263429929379048418168261354545296192150661798049803",
"11315559888424407479931655516950918246292226956735875477128098642493645442885",
"9085246104369332535685859617274924913745082010132213151326237416498283604205",
"9134570291644588790280243964839756458979229234489450815770496508915817080427",
"11693905103915021780876273452615664276026650875518285181822943282139969023577",
"5879106458665102974747699563173938024304064643034744137410223694531902217705",
"13229839545561479759360729184929380515140303444679926082391608258681256096241",
"19043464477920061724907038405758456350458953482221566081614411461986847748780",
"20461504558718815833416065710252799753783243729827475763390812613122344062583",
"11387864146422976952618746545175012189134820851985026935644049600192531932877",
"1741061806806568345561481699340284023445487586947866557772499380183034745921",
"8281678371325264497685530306636722155770489597467590253715093705065889484872",
"5442287619842418174080711079412459887566431712926453351358348572156486369433",
"251208284458654419567334492917447233000101137462755198234973385357625651988",
"4924684589580492587408155657007320773199299327395457071164148252967688639022",
"18830013381486777662957619985042824136817847699139216345601478130729636773396",
"10378872594323886692876793504818686974339875380631905612531753510813826878377",
"5949576954464334741230835410879956411628989295899973668205708540152152592804",
"1331384545855414732292166417351724604550548119358088171913999886448271368974",
"8090612591661721659646591550877326873232289563585084321020139849647751971539",
"1616695938398721359840827968204612526188730909593422441996076911282433841445",
"6173910428375719944077045936867968490081416940324309561402841757256524618597",
"10399158422450536696974881956639077838833346463175143160019880945542583933171",
"5626429095897124207156124490507908209587012871145023346017432413095568182324",
"3417292703452231761591646653228174496476875900947979800355662763247375459888",
"16428092485622287734678283407472772044095615896835099035757834469905278697861",
"10463520092125304272949463260343579455527605141554232943612666532455601096485",
"10920224218847118274673611993949547767648616455525266455675730464122182558172",
"8452180460153096160050048497128429858757337592761902223428525848217500819238",
"16861670587573306080916413542687929804182763021151501784772078690638292294735",
"8074575430526984547794921357817877410084423503688639002651967748475755692031",
"17661703078592030223747154252403083509747079642354406061904075345034789588407",
"4665657866917714459862863812984671925681256238528158997123954598101047930810",
"12375385846140647620810576122063772809835163014184160738054191119745615954546",
"555754904071185740161455603877488872204074104081798484529386241307137773748",
"330020700462587019340169726075378873445023466696048803946092884457771874059",
"2814394786082378813837397022482012997635306823685357420279776882567324835247",
"8428987111868279310405804989679069678446936839144776934065078191801177203437",
"1100744686310625620681337526595375866707450436360612656271714053818123723234",
"20320735632149336884097993376985646159933288765910958982403840164939077443330",
"5172170812120803166278881838646098051512076780415744164442848535597470118644"
]
};

Expand Down
5 changes: 4 additions & 1 deletion prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRoom } from '../src/data/db';
import { addBulkIdentities, createRoom } from '../src/data/db';
import { createEthGroup } from '../src/data/db';
import addresses from './addresses';
async function main() {
Expand All @@ -15,10 +15,13 @@ async function main() {
await createRoom('SBC Experiments', 100000, 12, 20, 20, 'PUBLIC');
await createRoom('Ban Appeals', 10000, 1, 0, 5, 'PUBLIC', [], '666');
await createRoom('The Word', 100000, 12, 0, 0, 'PUBLIC', [], '007001');
const taz = await createRoom('TAZ', 100000, 12, 0, 0, 'PUBLIC');
await addBulkIdentities(taz!.roomId, addresses.taz);
const bcgd = await createRoom('Beacon Chain Genesis Depositors', 10000, 12, 0, 20, 'PUBLIC');
const sgf = await createRoom('Stateful Genesis Funders', 10000, 12, 0, 20, 'PUBLIC');
await createEthGroup('Beacon Chain Genesis Depositors', bcgd!.roomId, addresses.bcgd);
await createEthGroup('Stateful Genesis Funders', sgf!.roomId, addresses.sgf);

}

await main();
6 changes: 4 additions & 2 deletions src/data/db/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const prisma = new PrismaClient();

/**
* Creates a new room with the given name and optional parameters.
* @param {string} name - The name of the room.
* @param {string} roomName - The name of the room.
* @param {number} [rateLimit=10000] - The length of an epoch in milliseconds
* @param {number} [userMessageLimit=12] - The message limit per user per epoch
* @param {number} [numClaimCodes=0] - The number of claim codes to generate for the room.
Expand All @@ -33,7 +33,8 @@ export async function createRoom(
bandadaGroupId?: string,
bandadaAPIKey?: string,
membershipType?: string,
roomId?: string
roomId?: string,
encrypted?: string
): Promise<{ roomId: string; claimCodes: { claimcode: string }[] } | undefined | null> {
const claimCodes: { claimcode: string }[] = genClaimCodeArray(numClaimCodes);
const mockUsers: string[] = genMockUsers(approxNumMockUsers);
Expand Down Expand Up @@ -62,6 +63,7 @@ export async function createRoom(
bandadaAPIKey,
type,
membershipType,
encrypted,
claimCodes: {
create: claimCodes
},
Expand Down
18 changes: 17 additions & 1 deletion src/data/db/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ export async function addIdentityToBandadaRooms(
* @param {string} roomId - The ID of the room
* @param {string[]} ethAddresses - The list of Ethereum addresses to add to the group
*/

export async function createEthGroup(
name: string,
roomId: string,
Expand All @@ -325,3 +324,20 @@ export async function createEthGroup(
}
});
}


export async function addBulkIdentities(
roomId: string,
identities: string[]
) {
await prisma.rooms.update({
where: {
roomId: roomId
},
data: {
identities: {
push: identities
}
}
})
}
19 changes: 17 additions & 2 deletions src/endpoints/rooms/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
// findRoomsByIdentity,
createRoom,
removeRoom,
removeMessage
removeMessage,
addBulkIdentities
} from '../../data/db/';
import { MessageI, RoomI } from 'discreetly-interfaces';
import { RLNFullProof } from 'rlnjs';
Expand Down Expand Up @@ -134,6 +135,7 @@ router.post('/add', adminAuth, (req, res) => {
const bandadaAPIKey = roomMetadata.bandadaAPIKey;
const membershipType = roomMetadata.membershipType;
const roomId = roomMetadata.roomId;
const encrypted = roomMetadata.encrypted;
createRoom(
roomName,
rateLimit,
Expand All @@ -146,7 +148,8 @@ router.post('/add', adminAuth, (req, res) => {
bandadaGroupId,
bandadaAPIKey,
membershipType,
roomId
roomId,
encrypted
)
.then((result) => {
const response =
Expand Down Expand Up @@ -342,5 +345,17 @@ router.post('/setpassword/:id', limiter, asyncHandler(async (req: Request, res:
}
}))

router.post('/addIdentities', limiter, adminAuth, asyncHandler(async (req: Request, res: Response) => {
const { roomId, identities } = req.body as { roomId: string, identities: string[] };
try {
await addBulkIdentities(roomId, identities);
res.status(200).json({ success: true, message: `Identities added successfully to ${roomId}` });
} catch (error) {
pp(error, 'error');
res.status(500).send('Error adding identities');
}


}));

export default router;
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface addRoomData {
membershipType?: string;
roomId?: string;
admin?: boolean;
encrypted?: string;
discordIds?: string[];
}

Expand Down