timeout for getter

This commit is contained in:
Daniel Lugo 2020-01-14 18:08:18 -04:00
parent a72f6dd091
commit c3fff0a432
2 changed files with 4 additions and 4 deletions

View file

@ -868,7 +868,7 @@ const sendPayment = async (to, amount, memo, gun, user, SEA) => {
timestamp: Date.now()
}
const currOrderAddress = await Getters.currentOrderAddress(to, gun)
const currOrderAddress = await Getters.currentOrderAddress(to)
order.timestamp = Date.now()

View file

@ -1,12 +1,12 @@
const Key = require('./key')
const Utils = require('./utils')
/**
* @param {string} pub
* @param {import('./SimpleGUN').GUNNode} gun
* @returns {Promise<string>}
*/
exports.currentOrderAddress = async (pub, gun) => {
const currAddr = await gun.user(pub).get(Key.CURRENT_ORDER_ADDRESS).then()
exports.currentOrderAddress = async (pub) => {
const currAddr = await Utils.tryAndWait((gun) => gun.user(pub).get(Key.CURRENT_ORDER_ADDRESS).then())
if (typeof currAddr !== 'string') {
throw new TypeError('Expected user.currentOrderAddress to be an string')