2016-02-28 70 views
0

我有以下合約:復仇事件沒有顯示出來,但功能完成

Contract Store{ 

    event Purchase(address buyer, int item_id); 

    struct Product { 
     string name; 
     uint price; 
     string desc; 
     uint quantity; 
     bool enabled; 
    } 

    mapping (address => int) balances; 

    function buyProduct(uint id) returns(bool){ 
     if(products[id].quantity <= 0){ return false; } 

     balances[msg.sender] = balances[msg.sender] - int(products[id].price); 
     products[id].quantity--; 
     Purchase(msg.sender, id); 
     return true; 
     } 

} 

當我使用WEB3購買產品與Store.buyProduct,產品的購買製成,但不會觸發事件上前端。這裏是我的活動觀察員代碼:

var eventFilter = Store.deployed().Purchase({from: "0xe02b4fc50f429624937e9425e1243292857291e2"}, {fromBlock: 0, toBlock: 'latest'}); 

eventFilter.watch(function(error, event){ 
    console.log('hai'); 
    console.log(event); 
}); 

回答

0

Argh。它剛剛開始工作,我通過了一個uint的事件,但它期待着一個int

相關問題