Skip to content

Commit

Permalink
adding support for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
guy muroch committed Jul 3, 2023
1 parent 65925cd commit 6ae39c7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions examples/server-worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ app.post('/key-shares/generate', async (req: Request, res: Response) => {
.json({ message: 'Keystore is required' });
}

const owner_address = String(req.body['owner_address'] || '')
// The nonce of the owner within the SSV contract (increments after each validator registration), obtained using the ssv-scanner tool
const nonce = Number(req.body['nonce'] || '')

if (!owner_address.length) {
if (!nonce) {
return res
.status(constants.HTTP_STATUS_BAD_REQUEST)
.json({ message: 'Owner address is required' });
.json({ message: 'Nonce is required' });
}

const password = String(req.body['password'] || '');
Expand All @@ -80,12 +81,15 @@ app.post('/key-shares/generate', async (req: Request, res: Response) => {
const keyShares = new KeyShares();
keyShares.update({ operators, publicKey });

// The cluster owner address
const TEST_OWNER_ADDRESS = '0x81592c3de184a3e2c0dcb5a261bc107bfa91f494';

await keyShares.buildPayload({
publicKey,
operators,
encryptedShares,
},{
ownerAddress: owner_address,
ownerAddress: TEST_OWNER_ADDRESS,
ownerNonce: nonce,
privateKey
});
Expand All @@ -97,5 +101,6 @@ app.post('/key-shares/generate', async (req: Request, res: Response) => {
});

app.listen(port, () => {
console.log('brotherit!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
console.log(`⚡️[server]: Server is running at https://localhost:${port}`);
});

0 comments on commit 6ae39c7

Please sign in to comment.