Skip to content

Commit

Permalink
Merge pull request ethereum#1000 from eswarasai/master
Browse files Browse the repository at this point in the history
Initial commit to allow hex encoded transaction param
  • Loading branch information
yann300 authored Jan 29, 2018
2 parents 5e5a04c + d490708 commit 6c628a5
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/app/execution/txFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.indexOf('0x') === 0) {
dataHex = params.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) {
Expand Down

0 comments on commit 6c628a5

Please sign in to comment.