Merge pull request #1000 from eswarasai/master

Initial commit to allow hex encoded transaction param
pull/1/head
yann300 7 years ago committed by GitHub
commit 6c628a532c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      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.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) {

Loading…
Cancel
Save