order schema
This commit is contained in:
parent
219de3b67f
commit
40f1e939d7
1 changed files with 39 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @format
|
||||
*/
|
||||
/**
|
||||
* @typedef {object} HandshakeRequest
|
||||
|
|
@ -316,7 +316,6 @@ exports.isPartialOutgoing = item => {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {any} item
|
||||
* @returns {item is Outgoing}
|
||||
*/
|
||||
|
|
@ -337,3 +336,41 @@ exports.isOutgoing = item => {
|
|||
|
||||
return typeof obj.with === 'string' && messagesAreMessages
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} Order
|
||||
* @prop {string} from Public key of sender.
|
||||
* @prop {string} amount Encrypted
|
||||
* @prop {string} memo Encrypted
|
||||
* @prop {number} timestamp
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {any} item
|
||||
* @returns {item is Order}
|
||||
*/
|
||||
exports.isOrder = item => {
|
||||
if (typeof item !== 'object') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (item === null) {
|
||||
return false
|
||||
}
|
||||
|
||||
const obj = /** @type {Order} */ (item)
|
||||
|
||||
if (typeof obj.amount !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (typeof obj.from !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (typeof obj.memo !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
return typeof obj.timestamp === 'number'
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue