All files / src/transaction makeOutput.js

100% Statements 4/4
100% Branches 8/8
100% Functions 1/1
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20                13x 13x 1x   12x              
/**
 * @public
 * Create an Output from a Condition.
 * Note: Assumes the given Condition was generated from a single public key (e.g. a Ed25519 Condition)
 * @param {object} condition Condition (e.g. a Ed25519 Condition from `makeEd25519Condition()`)
 * @param {string} amount Amount of the output
 * @returns {object} An Output usable in a Transaction
 */
export default function makeOutput(condition, amount = '1') {
    if (typeof amount !== 'string') {
        throw new TypeError('`amount` must be of type string')
    }
    return {
        'amount': amount,
        condition,
        'public_keys': condition.details.hasOwnProperty('public_key') ?
            [condition.details.public_key] : [],
    }
}