Skip to content

Commit

Permalink
Customer server new endpoint to sign specific requests in cold mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mstamati authored and nadav-fireblocks committed Dec 4, 2024
1 parent e94e60c commit f82e7c0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/server/env/dev.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
KNOWN_API_KEYS=""
HSM_MODE=COLD
HSM_MODE=HOT
SIGNING_ORDER=RANDOM
14 changes: 7 additions & 7 deletions examples/server/src/dao/messages.dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ export const getMessagesStatus = async (requestsIds: string[]): Promise<MessageS
},
},
]).toArray();

if (stats.length > 0) {
const { total, pendingSign, signed, failed } = stats[0];
logger.info(`Full DB statistics: TOTAL: ${total}, PENDING_SIGN: ${pendingSign}, SIGNED: ${signed}, FAILED: ${failed}`);
} else {
logger.warn(`Could not read full DB statistics`);
}

const res = await txRef.find({ _id: { $in: requestsIds } }).toArray();
logger.info(`Results statistics: `+
`TOTAL: ${res.length}` +
`, PENDING_SIGN: ${res.filter((_) => _.status === "PENDING_SIGN").length}` +
`, SIGNED: ${res.filter((_) => _.status === "SIGNED").length}` +
`, FAILED: ${res.filter((_) => _.status === "FAILED").length}`);
logger.info(`Results statistics: ` +
`TOTAL: ${res.length}` +
`, PENDING_SIGN: ${res.filter((_) => _.status === "PENDING_SIGN").length}` +
`, SIGNED: ${res.filter((_) => _.status === "SIGNED").length}` +
`, FAILED: ${res.filter((_) => _.status === "FAILED").length}`);
return toMsgStatus(res);
};

Expand Down
10 changes: 10 additions & 0 deletions examples/server/src/routes/messages.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ msgRouter.post('/signAllPendingMessages',
},
);

msgRouter.post('/signRequest/:requestId',
async (req: Request<{ requestId: string }, {}, MessagesStatusRequest>, res: Response<MessagesStatusResponse>) => {
const { requestId } = req.params;
await hsmSignService.signMessages([requestId]);
const messagesStatusAfterSign = await messagesDao.getMessagesStatus([requestId]);

res.status(200).json({ statuses: messagesStatusAfterSign });
},
);


msgRouter.post(
'/messagesStatus',
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const AGENT_VERSION = '2.2.5';
export const AGENT_VERSION = '2.2.6';

0 comments on commit f82e7c0

Please sign in to comment.