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) { buildData: function (contractName, contract, contracts, isConstructor, funAbi, params, udapp, callback, callbackStep) {
var funArgs = '' var funArgs = ''
try {
funArgs = $.parseJSON('[' + params + ']')
} catch (e) {
callback('Error encoding arguments: ' + e)
return
}
var data = '' var data = ''
var dataHex = '' var dataHex = ''
if (!isConstructor || funArgs.length > 0) {
if (params.indexOf('0x') === 0) {
dataHex = params.replace('0x', '')
data = Buffer.from(dataHex, 'hex')
} else {
try { try {
data = helper.encodeParams(funAbi, funArgs) funArgs = $.parseJSON('[' + params + ']')
dataHex = data.toString('hex')
} catch (e) { } catch (e) {
callback('Error encoding arguments: ' + e) callback('Error encoding arguments: ' + e)
return return
} }
} if (!isConstructor || funArgs.length > 0) {
if (data.slice(0, 9) === 'undefined') { try {
dataHex = data.slice(9) data = helper.encodeParams(funAbi, funArgs)
} dataHex = data.toString('hex')
if (data.slice(0, 2) === '0x') { } catch (e) {
dataHex = data.slice(2) 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 var contractBytecode
if (isConstructor) { if (isConstructor) {

Loading…
Cancel
Save