src/api.js
/**
     * Creates a sell transaction for identity's data 
     * 
     * @param   {String}   identity            identity's contract address  
     * @param   {Object[]} saleNodes           List of nodes to be sold 
     * @param   {String}   saleNodes.label     Node label
     * @param   {Integer}  saleNodes.price     Node price
     * @param   {String}   privateKey          User's private key. Used to decrypt his data 
     * @param   {Integer}  [price=0]           Sale total price. Overrided by node's prices if it's null  
     * @returns {String}                       QRcode image uri
     * @memberof Api
     */
Creates a sell transaction for identity's data


Creates a sell transaction for identity ' s data
async sellIdentityData(identity, saleNodes, privateKey, price = 0) {
        if(!price) saleNodes.forEach(node => {  price += parseInt(node.price) })
        const sellerTree = await this.getIdentityData(identity, true, privateKey)
        saleNodes.map(node => { 
            let treeNode = IdentityDag.dfs(sellerTree, node.label) 
            node.data = treeNode.data
            node.salt = treeNode.salt
        })
        return QRCode.getQRUri(JSON.stringify({ identity, saleNodes, price }))
    }
async sellIdentityData ( identity , saleNodes , privateKey , price = 0 ) { if ( ! price ) saleNodes . forEach ( node => { price += parseInt ( node . price ) } ) const sellerTree = await this . getIdentityData ( identity , true , privateKey ) saleNodes . map ( node => { let treeNode = IdentityDag . dfs ( sellerTree , node . label ) node . data = treeNode . data node . salt = treeNode . salt } ) return QRCode . getQRUri ( JSON . stringify ( { identity , saleNodes , price } ) ) }
Creates a sell transaction for identity's data
Creates a sell transaction for identity ' s data
// --- Correct Implementation // --- Test Implementation //return { identity, saleNodes, price }