use on()
This commit is contained in:
parent
ad61133efe
commit
7ddf7c82f3
1 changed files with 12 additions and 12 deletions
|
|
@ -958,19 +958,19 @@ const sendPayment = async (to, amount, memo) => {
|
||||||
let timeoutID
|
let timeoutID
|
||||||
|
|
||||||
const invoice = await Promise.race([
|
const invoice = await Promise.race([
|
||||||
Utils.tryAndWait(
|
new Promise(res => {
|
||||||
gun =>
|
require('../Mediator')
|
||||||
gun
|
.getGun()
|
||||||
.user(to)
|
.user(to)
|
||||||
.get(Key.ORDER_TO_RESPONSE)
|
.get(Key.ORDER_TO_RESPONSE)
|
||||||
.get(orderID)
|
.get(orderID)
|
||||||
.then()
|
.on(inv => {
|
||||||
.then(v => {
|
if (typeof inv === 'string') {
|
||||||
clearTimeout(timeoutID)
|
clearTimeout(timeoutID)
|
||||||
return v
|
res(inv)
|
||||||
}),
|
}
|
||||||
v => typeof v !== 'string'
|
})
|
||||||
),
|
}),
|
||||||
new Promise((_, rej) => {
|
new Promise((_, rej) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
rej(new Error(ErrorCode.ORDER_NOT_ANSWERED_IN_TIME))
|
rej(new Error(ErrorCode.ORDER_NOT_ANSWERED_IN_TIME))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue