-function setAsyncActorKeys <T extends MActor> (actor: T) {
- return createPrivateAndPublicKeys()
- .then(({ publicKey, privateKey }) => {
- actor.publicKey = publicKey
- actor.privateKey = privateKey
- return actor.save()
- })
- .catch(err => {
- logger.error('Cannot set public/private keys of actor %d.', actor.url, { err })
- return actor
- })
+async function generateAndSaveActorKeys <T extends MActor> (actor: T) {
+ const { publicKey, privateKey } = await createPrivateAndPublicKeys()
+
+ actor.publicKey = publicKey
+ actor.privateKey = privateKey
+
+ return actor.save()