wire sendpayment to socket
This commit is contained in:
parent
9a10bf324f
commit
4947a4dbb6
1 changed files with 34 additions and 0 deletions
|
|
@ -296,6 +296,7 @@ class Mediator {
|
||||||
this.sendHRWithInitialMsg
|
this.sendHRWithInitialMsg
|
||||||
)
|
)
|
||||||
socket.on(Action.SEND_MESSAGE, this.sendMessage)
|
socket.on(Action.SEND_MESSAGE, this.sendMessage)
|
||||||
|
socket.on(Action.SEND_PAYMENT, this.sendPayment)
|
||||||
socket.on(Action.SET_AVATAR, this.setAvatar)
|
socket.on(Action.SET_AVATAR, this.setAvatar)
|
||||||
socket.on(Action.SET_DISPLAY_NAME, this.setDisplayName)
|
socket.on(Action.SET_DISPLAY_NAME, this.setDisplayName)
|
||||||
|
|
||||||
|
|
@ -563,6 +564,39 @@ class Mediator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Readonly<{ uuid: string, recipientPub: string, amount: number, memo: string, token: string }>} reqBody
|
||||||
|
*/
|
||||||
|
sendPayment = async reqBody => {
|
||||||
|
try {
|
||||||
|
const { recipientPub, amount, memo, token } = reqBody
|
||||||
|
|
||||||
|
await throwOnInvalidToken(token)
|
||||||
|
|
||||||
|
await API.Actions.sendPayment(
|
||||||
|
recipientPub,
|
||||||
|
amount,
|
||||||
|
memo,
|
||||||
|
gun,
|
||||||
|
user,
|
||||||
|
mySEA
|
||||||
|
)
|
||||||
|
|
||||||
|
this.socket.emit(Action.SEND_PAYMENT, {
|
||||||
|
ok: true,
|
||||||
|
msg: null,
|
||||||
|
origBody: reqBody
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
this.socket.emit(Action.SEND_PAYMENT, {
|
||||||
|
ok: false,
|
||||||
|
msg: err.message,
|
||||||
|
origBody: reqBody
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Readonly<{ avatar: string|null , token: string }>} body
|
* @param {Readonly<{ avatar: string|null , token: string }>} body
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue