Skip to content

Commit

Permalink
second concept draft recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
serapath authored and yann300 committed Dec 6, 2017
1 parent 2e08f26 commit 6281253
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
16 changes: 11 additions & 5 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,8 @@ function run () {
/****************************************************************************
RECORDER
****************************************************************************/
var modal = { show: function showModal (args) { console.log('@TODO: open modal') } }

var recorder = new Recorder({ events: {
txlogger: txLogger.event,
udapp: udapp.event,
executioncontext: executionContext.event
}})

Expand All @@ -801,7 +799,7 @@ function run () {
recordButton.onclick = () => {
var txJSON = JSON.stringify(recorder.getAll(), null, 2)
copy2clipboard(txJSON)
modal.show(txJSON)
modalDialogCustom.alert(txJSON)
}
runButton.onclick = () => { // on modal OR run tab
var txArray = recorder.getAll()
Expand All @@ -818,5 +816,13 @@ function run () {
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) }
}
}
12 changes: 6 additions & 6 deletions src/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ class Recorder {
self.event = new EventManager()
self.data = { journal: [] }
opts.events.txlogger.register('initiatingTransaction', (stamp, tx) => {
var { from, to, value, gas, data /*, gasPrice?, nonce? */ } = tx
from = self.translate(from) // see comments above regarding what `translate(...)` is doing
var { from, to, value, gas, data } = tx
from = self.translate(from)
to = self.translate(to)
var deTx = { from, to, value, gas, data /*, gasPrice?, nonce? */ }
var deTx = { from, to, value, gas, data }
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
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
console.log('@TODO: should i do something here?')
})
Expand Down Expand Up @@ -49,7 +49,7 @@ class Recorder {
var self = this
self.data.journal.push({ timestamp, record })
}
getAllJSON () {
getAll () {
var self = this
var records = [].concat(self.data.journal)
return records.sort((A, B) => {
Expand Down

0 comments on commit 6281253

Please sign in to comment.