fix recorder

fix#476
yann300 4 years ago
parent f3deff0b7c
commit b9a82e6c8e
  1. 1
      apps/remix-ide/src/app/tabs/runTab/model/recorder.js
  2. 17
      apps/remix-ide/src/app/tabs/runTab/recorder.js

@ -4,7 +4,6 @@ var remixLib = require('@remix-project/remix-lib')
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
var format = remixLib.execution.txFormat var format = remixLib.execution.txFormat
var txHelper = remixLib.execution.txHelper var txHelper = remixLib.execution.txHelper
var helper = require('../../../../lib/helper.js')
/** /**
* Record transaction as long as the user create them. * Record transaction as long as the user create them.

@ -1,4 +1,6 @@
var yo = require('yo-yo') var yo = require('yo-yo')
var remixLib = require('@remix-project/remix-lib')
var EventManager = remixLib.EventManager
import { Plugin } from '@remixproject/engine' import { Plugin } from '@remixproject/engine'
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
var css = require('../styles/run-tab-styles') var css = require('../styles/run-tab-styles')
@ -9,6 +11,8 @@ var modalDialogCustom = require('../../ui/modal-dialog-custom')
var modalDialog = require('../../ui/modaldialog') var modalDialog = require('../../ui/modaldialog')
var confirmDialog = require('../../ui/confirmDialog') var confirmDialog = require('../../ui/confirmDialog')
var helper = require('../../../lib/helper.js')
const profile = { const profile = {
name: 'recorder', name: 'recorder',
methods: ['runScenario'], methods: ['runScenario'],
@ -24,6 +28,7 @@ class RecorderUI extends Plugin {
this.recorder = recorder this.recorder = recorder
this.logCallBack = logCallBack this.logCallBack = logCallBack
this.config = config this.config = config
this.event = new EventManager()
} }
render () { render () {
@ -39,12 +44,16 @@ class RecorderUI extends Plugin {
onclick=${this.triggerRecordButton.bind(this)} title="Save Transactions" aria-hidden="true"> onclick=${this.triggerRecordButton.bind(this)} title="Save Transactions" aria-hidden="true">
</i>` </i>`
this.runButton.onclick = this.runScenario.bind(this) this.runButton.onclick = () => {
const file = this.config.get('currentFile')
if (!file) return modalDialogCustom.alert('A scenario file has to be selected')
this.runScenario(file)
}
} }
runScenario (file) { runScenario (file) {
file = file || this.config.get('currentFile') if (!file) return modalDialogCustom.alert('Unable to run scenerio, no specified scenario file')
var continueCb = (error, continueTxExecution, cancelCb) => { var continueCb = (error, continueTxExecution, cancelCb) => {
if (error) { if (error) {
var msg = typeof error !== 'string' ? error.message : error var msg = typeof error !== 'string' ? error.message : error
@ -86,7 +95,7 @@ class RecorderUI extends Plugin {
this.event.trigger('newScenario', [abi, address, contractName]) this.event.trigger('newScenario', [abi, address, contractName])
}) })
}).catch((error) => cb(error)) }).catch((error) => modalDialogCustom.alert(error))
} }
getConfirmationCb (modalDialog, confirmDialog) { getConfirmationCb (modalDialog, confirmDialog) {
@ -133,7 +142,7 @@ class RecorderUI extends Plugin {
} }
saveScenario (promptCb, cb) { saveScenario (promptCb, cb) {
var txJSON = JSON.stringify(this.getAll(), null, 2) var txJSON = JSON.stringify(this.recorder.getAll(), null, 2)
var path = this.fileManager.currentPath() var path = this.fileManager.currentPath()
promptCb(path, input => { promptCb(path, input => {
var fileProvider = this.fileManager.fileProviderOf(path) var fileProvider = this.fileManager.fileProviderOf(path)

Loading…
Cancel
Save