From 5d38592aac22876fb6d70e29b42482221b74e598 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 20 Oct 2020 10:22:52 +0200 Subject: [PATCH] fix recorder --- .../src/app/tabs/runTab/model/recorder.js | 1 - .../remix-ide/src/app/tabs/runTab/recorder.js | 21 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/runTab/model/recorder.js b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js index 1980b9c68d..dea794a827 100644 --- a/apps/remix-ide/src/app/tabs/runTab/model/recorder.js +++ b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js @@ -4,7 +4,6 @@ var remixLib = require('@remix-project/remix-lib') var EventManager = remixLib.EventManager var format = remixLib.execution.txFormat var txHelper = remixLib.execution.txHelper -var helper = require('../../../../lib/helper.js') /** * Record transaction as long as the user create them. diff --git a/apps/remix-ide/src/app/tabs/runTab/recorder.js b/apps/remix-ide/src/app/tabs/runTab/recorder.js index bc7387d1de..48aa809eed 100644 --- a/apps/remix-ide/src/app/tabs/runTab/recorder.js +++ b/apps/remix-ide/src/app/tabs/runTab/recorder.js @@ -1,4 +1,6 @@ var yo = require('yo-yo') +var remixLib = require('@remix-project/remix-lib') +var EventManager = remixLib.EventManager import { Plugin } from '@remixproject/engine' var csjs = require('csjs-inject') var css = require('../styles/run-tab-styles') @@ -9,6 +11,8 @@ var modalDialogCustom = require('../../ui/modal-dialog-custom') var modalDialog = require('../../ui/modaldialog') var confirmDialog = require('../../ui/confirmDialog') +var helper = require('../../../lib/helper.js') + const profile = { name: 'recorder', methods: ['runScenario'], @@ -23,7 +27,8 @@ class RecorderUI extends Plugin { this.blockchain = blockchain this.recorder = recorder this.logCallBack = logCallBack - this.config = config + this.config = config + this.event = new EventManager() } render () { @@ -39,12 +44,16 @@ class RecorderUI extends Plugin { onclick=${this.triggerRecordButton.bind(this)} title="Save Transactions" aria-hidden="true"> ` - 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) { - file = file || this.config.get('currentFile') + runScenario (file) { + if (!file) return modalDialogCustom.alert('Unable to run scenerio, no specified scenario file') var continueCb = (error, continueTxExecution, cancelCb) => { if (error) { var msg = typeof error !== 'string' ? error.message : error @@ -86,7 +95,7 @@ class RecorderUI extends Plugin { this.event.trigger('newScenario', [abi, address, contractName]) }) - }).catch((error) => cb(error)) + }).catch((error) => modalDialogCustom.alert(error)) } getConfirmationCb (modalDialog, confirmDialog) { @@ -133,7 +142,7 @@ class RecorderUI extends Plugin { } 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() promptCb(path, input => { var fileProvider = this.fileManager.fileProviderOf(path)