Merge pull request #145 from axic/patch/vm-events

Support event logs in VM mode
pull/1/head
chriseth 9 years ago
commit 456d4949fe
  1. 25
      assets/js/universal-dapp.js

@ -150,13 +150,8 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
});
$events = $('<div class="events"/>');
if (self.options.vm){
self.vm.on('afterTx', function(response){
// TODO: parse/use reponse.vm.logs
});
} else {
var eventFilter = web3contract.at(address).allEvents();
eventFilter.watch(function(err,response){
var parseLogs = function(err,response) {
$event = $('<div class="event" />')
var $close = $('<div class="udapp-close" />')
@ -167,7 +162,21 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
.append( $close );
$events.append( $event );
})
}
if (self.options.vm){
self.vm.on('afterTx', function(response){
for (var i in response.vm.logs) {
// [address, topics, mem]
var log = response.vm.logs[i];
// FIXME: parse based on ABI (match event name + decode values)
parseLogs(null, { event: log[1][0].toString('hex'), args: '0x' + log[2].toString('hex') });
}
});
} else {
var eventFilter = web3contract.at(address).allEvents();
eventFilter.watch(parseLogs);
}
$instance.append( $title );

Loading…
Cancel
Save