This commit is contained in:
Daniel Lugo 2020-06-02 13:06:18 -04:00
parent e46e79405d
commit dba537e9b0

View file

@ -1,3 +1,6 @@
/**
* @format
*/
const Key = require('./key')
const Utils = require('./utils')
@ -5,8 +8,13 @@ const Utils = require('./utils')
* @param {string} pub
* @returns {Promise<string>}
*/
exports.currentOrderAddress = async (pub) => {
const currAddr = await Utils.tryAndWait((gun) => 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')
@ -19,11 +27,14 @@ exports.currentOrderAddress = async (pub) => {
* @param {string} pub
* @returns {Promise<string|null>}
*/
exports.userToIncomingID = async (pub) => {
const incomingID = await require('../Mediator').getUser().get(Key.USER_TO_INCOMING).get(pub).then()
exports.userToIncomingID = async pub => {
const incomingID = await require('../Mediator')
.getUser()
.get(Key.USER_TO_INCOMING)
.get(pub)
.then()
if (typeof incomingID === 'string') return incomingID
return null
}
}