|
|
@ -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) { |
|
|
|