second concept draft recorder

pull/1/head
serapath 7 years ago committed by yann300
parent 2e08f26608
commit 6281253d8a
  1. 16
      src/app.js
  2. 12
      src/recorder.js

@ -778,10 +778,8 @@ function run () {
/**************************************************************************** /****************************************************************************
RECORDER RECORDER
****************************************************************************/ ****************************************************************************/
var modal = { show: function showModal (args) { console.log('@TODO: open modal') } }
var recorder = new Recorder({ events: { var recorder = new Recorder({ events: {
txlogger: txLogger.event, udapp: udapp.event,
executioncontext: executionContext.event executioncontext: executionContext.event
}}) }})
@ -801,7 +799,7 @@ function run () {
recordButton.onclick = () => { recordButton.onclick = () => {
var txJSON = JSON.stringify(recorder.getAll(), null, 2) var txJSON = JSON.stringify(recorder.getAll(), null, 2)
copy2clipboard(txJSON) copy2clipboard(txJSON)
modal.show(txJSON) modalDialogCustom.alert(txJSON)
} }
runButton.onclick = () => { // on modal OR run tab runButton.onclick = () => { // on modal OR run tab
var txArray = recorder.getAll() var txArray = recorder.getAll()
@ -818,5 +816,13 @@ function run () {
selectContractNames.value)) selectContractNames.value))
*/ */
} }
function copy2clipboard (json) { console.log('@TODO: copy 2 clipboard') } function copy2clipboard (json) {
var textarea = document.createElement('textarea')
textarea.textContent = json
document.body.appendChild(textarea)
textarea.select()
try { document.execCommand('copy') }
catch (e) { }
finally { document.body.removeChild(textarea) }
}
} }

@ -10,17 +10,17 @@ class Recorder {
self.event = new EventManager() self.event = new EventManager()
self.data = { journal: [] } self.data = { journal: [] }
opts.events.txlogger.register('initiatingTransaction', (stamp, tx) => { opts.events.txlogger.register('initiatingTransaction', (stamp, tx) => {
var { from, to, value, gas, data /*, gasPrice?, nonce? */ } = tx var { from, to, value, gas, data } = tx
from = self.translate(from) // see comments above regarding what `translate(...)` is doing from = self.translate(from)
to = self.translate(to) to = self.translate(to)
var deTx = { from, to, value, gas, data /*, gasPrice?, nonce? */ } var deTx = { from, to, value, gas, data }
self.append(stamp, deTx) self.append(stamp, deTx)
}) })
opts.events.txlogger.register('transactionExecuted', args => { opts.events.udapp.register('transactionExecuted', args => {
var [err, from, to, data, isUserCall, result, stamp] = args var [err, from, to, data, isUserCall, result, stamp] = args
console.log('@TODO: should i do something here?') console.log('@TODO: should i do something here?')
}) })
opts.events.txlogger.register('callExecuted', args => { opts.events.udapp.register('callExecuted', args => {
var [err, from, to, data, isUserCall, result, stamp] = args var [err, from, to, data, isUserCall, result, stamp] = args
console.log('@TODO: should i do something here?') console.log('@TODO: should i do something here?')
}) })
@ -49,7 +49,7 @@ class Recorder {
var self = this var self = this
self.data.journal.push({ timestamp, record }) self.data.journal.push({ timestamp, record })
} }
getAllJSON () { getAll () {
var self = this var self = this
var records = [].concat(self.data.journal) var records = [].concat(self.data.journal)
return records.sort((A, B) => { return records.sort((A, B) => {

Loading…
Cancel
Save