
var events = require('events')
var util = require('util')
var web3 = require('web3')


function Contract (source) {
  this.source = source
  this.instance = null
  this.name = ''
  this.deploying = false
}
util.inherits(Contract, events.EventEmitter)


Contract.prototype.compile = async function () {
  try {
    return await web3.eth.compile.solidity(this.source)
  } catch (e) {
    console.log(e)
  }
}

Contract.prototype.deploy = function (accountAddress) {
  var self = this

  var compiled = self.compile()
    , contractName = Object.keys(compiled)[0]
    , Contract = web3.eth.contract(compiled[contractName].info.abiDefinition)

  Contract.new(
    0, // (uint initialValue)
    {
      from: accountAddress,
      data: compiled[contractName].code,
      gas: 1000000
    },
    function (err, contract) {
      if (err) return done(err)

      if (!contract.address) {
        self.deploying = true
        self.emit('deploying', contract)
      }
      else {
        self.instance = contract
        self.deploying = false
        self.emit('deployed', self.instance)
      }
  })
}

Contract.prototype.init = function (contractAddress) {
  var compiled = this.compile()
    , contractName = Object.keys(compiled)[0]
    , abiDefinition = compiled[contractName].info.abiDefinition

  this.instance = web3.eth.contract(abiDefinition).at(contractAddress)
}

module.exports = Contract

@@ -1,16 +1,19 @@
 %0A
-var
+import
  events 
 = re
@@ -12,92 +12,77 @@
 nts 
-= require('events')%0Avar util = require('util')%0Avar web3 = require(
+from 'events'%0Aimport util from 'util'%0Aimport web3 from 
 'web3'
-)
 %0A%0A%0A
-function
+class
  Con
@@ -91,19 +91,76 @@
 act 
-(source) %7B%0A
+extends events.EventEmitter %7B%0A  constructor(source) %7B%0A    super()%0A  
   th
@@ -180,16 +180,18 @@
 ource%0A  
+ 
+ 
 this.ins
@@ -203,16 +203,18 @@
  = null%0A
+  
   this.n
@@ -224,16 +224,18 @@
  = ''%0A  
+ 
+ 
 this.dep
@@ -253,248 +253,109 @@
 lse%0A
-%7D%0Autil.inherits(Contract, events.EventEmitter)%0A%0A%0AContract.prototype.compile = async function () %7B%0A  try %7B%0A    return await web3.eth.compile.solidity(this.source)%0A  %7D catch (e) %7B%0A    console.log(e)%0A  %7D%0A%7D%0A%0AContract.prototype.deploy = function
+  %7D%0A%0A  async compile () %7B%0A    return await web3.eth.compile.solidity(this.source)%0A  %7D%0A%0A  async deploy
  (ac
@@ -366,24 +366,26 @@
 tAddress) %7B%0A
+  
   var self =
@@ -391,16 +391,18 @@
 = this%0A%0A
+  
   var co
@@ -409,16 +409,22 @@
 mpiled =
+ await
  self.co
@@ -427,32 +427,34 @@
 f.compile()%0A    
+ 
+ 
 , contractName =
@@ -475,24 +475,26 @@
 ompiled)%5B0%5D%0A
+  
     , Contra
@@ -560,16 +560,18 @@
 ition)%0A%0A
+  
   Contra
@@ -582,16 +582,18 @@
 ew(%0A    
+ 
+ 
 0, // (u
@@ -614,24 +614,26 @@
 ue)%0A    
+  
 %7B%0A      
 from: ac
@@ -624,16 +624,18 @@
 %7B%0A      
+ 
+ 
 from: ac
@@ -648,16 +648,18 @@
 ddress,%0A
+  
       da
@@ -697,16 +697,18 @@
 ,%0A      
+  
 gas: 100
@@ -720,11 +720,15 @@
     
+  
 %7D,%0A
+  
     
@@ -756,24 +756,26 @@
 ct) %7B%0A      
+ 
+ 
 if (err) ret
@@ -791,24 +791,26 @@
 err)%0A%0A      
+  
 if (!contrac
@@ -822,32 +822,34 @@
 ress) %7B%0A        
+ 
+ 
 self.deploying =
@@ -854,16 +854,18 @@
  = true%0A
+  
         
@@ -903,18 +903,22 @@
 )%0A      
-%7D%0A
+  %7D%0A  
       el
@@ -922,16 +922,18 @@
  else %7B%0A
+  
         
@@ -957,32 +957,34 @@
 ontract%0A        
+  
 self.deploying =
@@ -990,16 +990,18 @@
 = false%0A
+  
         
@@ -1047,52 +1047,36 @@
     
+  
 %7D%0A  
+ 
+ 
 %7D)%0A
+  
 %7D%0A%0A
-Contract.prototype.init = function
+  async init
  (co
@@ -1092,16 +1092,18 @@
 ress) %7B%0A
+  
   var co
@@ -1110,16 +1110,22 @@
 mpiled =
+ await
  this.co
@@ -1132,24 +1132,26 @@
 mpile()%0A    
+  
 , contractNa
@@ -1176,24 +1176,26 @@
 ompiled)%5B0%5D%0A
+  
     , abiDef
@@ -1247,16 +1247,18 @@
 nition%0A%0A
+  
   this.i
@@ -1324,27 +1324,29 @@
 ss)%0A
-%7D%0A%0Amodule.exports =
+  %7D%0A%7D%0A%0Aexport default
  Con

Use class, module and async