From 4730ca995f56f419532cab77b3b4150d0caa6cf9 Mon Sep 17 00:00:00 2001 From: Eswara Sai Date: Mon, 22 Jan 2018 02:01:32 +0530 Subject: [PATCH] Initial commit to allow hex encoded transaction param --- src/app/execution/txFormat.js | 36 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/app/execution/txFormat.js b/src/app/execution/txFormat.js index dcc116e0d9..7c93d80c05 100644 --- a/src/app/execution/txFormat.js +++ b/src/app/execution/txFormat.js @@ -47,28 +47,34 @@ module.exports = { */ buildData: function (contractName, contract, contracts, isConstructor, funAbi, params, udapp, callback, callbackStep) { var funArgs = '' - try { - funArgs = $.parseJSON('[' + params + ']') - } catch (e) { - callback('Error encoding arguments: ' + e) - return - } var data = '' var dataHex = '' - if (!isConstructor || funArgs.length > 0) { + + if (params.startsWith('"0x')) { + dataHex = params.match(/"(.*?)"/)[1].replace('0x', '') + data = Buffer.from(dataHex, 'hex') + } else { try { - data = helper.encodeParams(funAbi, funArgs) - dataHex = data.toString('hex') + funArgs = $.parseJSON('[' + params + ']') } catch (e) { callback('Error encoding arguments: ' + e) return } - } - if (data.slice(0, 9) === 'undefined') { - dataHex = data.slice(9) - } - if (data.slice(0, 2) === '0x') { - dataHex = data.slice(2) + if (!isConstructor || funArgs.length > 0) { + try { + data = helper.encodeParams(funAbi, funArgs) + dataHex = data.toString('hex') + } catch (e) { + callback('Error encoding arguments: ' + e) + return + } + } + if (data.slice(0, 9) === 'undefined') { + dataHex = data.slice(9) + } + if (data.slice(0, 2) === '0x') { + dataHex = data.slice(2) + } } var contractBytecode if (isConstructor) {