From 6ddbbb41ac110d183fbf3819f304fe727ea6b486 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 18:54:34 +0100 Subject: [PATCH] remove data from record and display decoed values --- src/recorder.js | 12 ++++++++++-- src/universal-dapp.js | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/recorder.js b/src/recorder.js index 1300f936d2..80f2ab0265 100644 --- a/src/recorder.js +++ b/src/recorder.js @@ -2,7 +2,9 @@ var remixLib = require('remix-lib') var EventManager = remixLib.EventManager var ethutil = require('ethereumjs-util') var executionContext = require('./execution-context') +var format = require('./app/execution/txFormat') var async = require('async') +var modal = require('./app/ui/modal-dialog-custom') /** * Record transaction as long as the user create them. @@ -22,10 +24,10 @@ class Recorder { opts.events.udapp.register('initiatingTransaction', (timestamp, tx, payLoad) => { if (tx.useCall) return var { from, to, value } = tx - var record = { value, parameters: { definition: payLoad.funAbi, values: payLoad.funArgs } } // convert to and from to tokens if (this.data._listen) { + var record = { value, parameters: { definitions: payLoad.funAbi, values: payLoad.funArgs } } if (!to) { var selectedContract = self._api.getSelectedContract() if (selectedContract) { @@ -33,6 +35,7 @@ class Recorder { var sha3 = ethutil.bufferToHex(ethutil.sha3(abi)) record.abi = sha3 record.contractName = selectedContract.name + record.bytecode = payLoad.contractBytecode self.data._abis[sha3] = abi } } else { @@ -146,7 +149,12 @@ class Recorder { self.setListen(false) async.eachSeries(records, function (tx, cb) { var record = self.resolveAddress(tx.record, accounts, options) - + var data = format.encodeData(tx.record.parameters.definitions, tx.record.parameters.values, tx.record.bytecode) + if (data.error) { + modal.alert(data.error) + } else { + record.data = data.data + } self._api.udapp().rerunTx(record, function (err, txResult) { if (err) { console.error(err) diff --git a/src/universal-dapp.js b/src/universal-dapp.js index 6632b162f0..95e1d5b432 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -476,7 +476,7 @@ UniversalDApp.prototype.rerunTx = function (args, cb) { UniversalDApp.prototype.runTx = function (args, cb) { var self = this var tx = { to: args.to, data: args.data.dataHex, useCall: args.useCall } - var payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs } // contains decoded parameters + var payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs, contractBytecode: args.data.contractBytecode } // contains decoded parameters var pipeline = [queryGasLimit, queryValue, queryAddress, runTransaction] var env = { self, args, tx, payLoad } execute(pipeline, env, cb)