aboutsummaryrefslogblamecommitdiffstats
path: root/ui/app/components/pending-tx-details.js
blob: 04e9cd2cd198fe62372cb8c657246a985f3f3b5c (plain) (tree)
1
2
3
4
5
6
7
8
9



                                            
                                                        


                                                        
                                                          
                                        







                                     
                                       
 
                           

                           

                                      


                                                                  
 
                                            
 

                                                                                    
          

              









                                                 
                                                      

                             
                                                       











                                            
         
 



















                                                                    

           


                                                                  

           







                                                             
           












                                                                              

      
   
 
 
                                                

                           

                                      


                                                                  










                                                       
                                                   






                                 
                                                   


                       
 
 
















                                                                 
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits

const MiniAccountPanel = require('./mini-account-panel')
const addressSummary = require('../util').addressSummary
const readableDate = require('../util').readableDate
const formatBalance = require('../util').formatBalance
const nameForAddress = require('../../lib/contract-namer')
const BN = require('ethereumjs-util').BN

module.exports = PendingTxDetails

inherits(PendingTxDetails, Component)
function PendingTxDetails () {
  Component.call(this)
}

const PTXP = PendingTxDetails.prototype

PTXP.render = function () {
  var props = this.props
  var txData = props.txData

  var txParams = txData.txParams || {}
  var address = txParams.from || props.selectedAddress
  var identity = props.identities[address] || { address: address }
  var account = props.accounts[address] || { address: address }

  var isContractDeploy = !('to' in txParams)

  var maxCost = (new BN(txParams.value, 16) + new BN(txParams.gas, 16)).toString(16)

  return (
    h('div', [

      h('.flex-row.flex-center', {
        style: {
          maxWidth: '100%',
        },
      }, [

        h(MiniAccountPanel, {
          attrs: [
            identity.name,
            addressSummary(address, 6, 4, false),
            formatBalance(identity.balance).formatted,
          ],
          imageSeed: address,
          imageifyIdenticons: props.imageifyIdenticons,
          picOrder: 'right',
        }),

        h('img', {
          src: 'images/forward-carrat.svg',
          style: {
            padding: '5px 6px 0px 10px',
            height: '48px',
          },
        }),

        this.miniAccountPanelForRecipient(),
      ]),

      h('style', `
        .table-box {
          margin: 7px 6px 0px 6px;
        }
        .table-box .row {
          margin: 0px;
          background: rgb(236,236,236);
          display: flex;
          justify-content: space-between;
          font-family: Montserrat Light, sans-serif;
          font-size: 13px;
          padding: 5px 15px;
        }
      `),

      h('.table-box', [

        h('.row', [
          h('.cell.label', 'Amount'),
          h('.cell.value', formatBalance(txParams.value).formatted),
        ]),

        h('.cell.row', [
          h('.cell.label', 'Max Transaction Fee'),
          h('.cell.value', formatBalance(txParams.gas).formatted),
        ]),

        h('.cell.row', {
          style: {
            fontFamily: 'Montserrat Regular',
            background: 'rgb(216,216,216)',
          },
        }, [
          h('.cell.label', 'Max Total'),
          h('.cell.value', formatBalance(maxCost).formatted),
        ]),

        h('.cell.row', {
          style: {
            background: '#f7f7f7',
            paddingBottom: '0px',
          }
        }, [
          h('.cell.label'),
          h('.cell.value', `Data included: ${txParams.data.length - 2} bytes`)
        ])
      ]), // End of Table

      this.warnIfNeeded(),

    ])
  )
}

PTXP.miniAccountPanelForRecipient = function() {
  var props = this.props
  var txData = props.txData

  var txParams = txData.txParams || {}
  var address = txParams.from || props.selectedAddress
  var identity = props.identities[address] || { address: address }
  var account = props.accounts[address] || { address: address }

  var isContractDeploy = !('to' in txParams)

  // If it's not a contract deploy, send to the account
  if (!isContractDeploy) {
    return h(MiniAccountPanel, {
      attrs: [
        nameForAddress(txParams.to),
        addressSummary(txParams.to, 6, 4, false),
      ],
      imageSeed: address,
      imageifyIdenticons: props.imageifyIdenticons,
      picOrder: 'left',
    })
  } else {
     return h(MiniAccountPanel, {
      attrs: [
        'New Contract'
      ],
      imageifyIdenticons: props.imageifyIdenticons,
      picOrder: 'left',
    })
  }
}

// Should analyze if there is a DELEGATECALL opcode
// in the recipient contract, and show a warning if so.
PTXP.warnIfNeeded = function() {
  return null

  return h('span.error', {
    style: {
      fontFamily: 'Montserrat Light',
      fontSize: '13px',
      display: 'flex',
      justifyContent: 'center',
    }
  }, [
    h('i.fa.fa-lg.fa-info-circle', { style: { margin: '5px' } }),
    h('span', ' Your identity may be used in other contracts!'),
  ])
}