diff --git a/remix-lib/src/execution/txFormat.js b/remix-lib/src/execution/txFormat.js index b462700866..1c984f6f7e 100644 --- a/remix-lib/src/execution/txFormat.js +++ b/remix-lib/src/execution/txFormat.js @@ -169,7 +169,7 @@ module.exports = { * @param {Function} callbackDeployLibrary - callbackDeployLibrary */ buildData: function (contractName, contract, contracts, isConstructor, funAbi, params, callback, callbackStep, callbackDeployLibrary) { - var funArgs = '' + var funArgs = [] var data = '' var dataHex = '' @@ -179,9 +179,32 @@ module.exports = { data = Buffer.from(dataHex, 'hex') } else { try { - params = params.replace(/(^|,\s+|,)(\d+)(\s+,|,|$)/g, '$1"$2"$3') // replace non quoted number by quoted number - params = params.replace(/(^|,\s+|,)(0[xX][0-9a-fA-F]+)(\s+,|,|$)/g, '$1"$2"$3') // replace non quoted hex string by quoted hex string - funArgs = JSON.parse('[' + params + ']') + if (params.length > 0) { + params = params.split(',') + for (let i = 0; i < params.length; i++) { + let param = params[i].trim() + if (param.charAt(0) === '"') { + if (param.charAt(param.length - 1) === '"') { + funArgs.push(param.slice(1, param.length - 1)) + } else { + let lastIndex = false + let paramStr = param.slice(1, param.length) + for (let j = i + 1; !lastIndex; j++) { + if (params[j].charAt(params[j].length - 1) === '"') { + paramStr += ',' + params[j].slice(0, params[j].length - 1) + i = j + funArgs.push(paramStr) + lastIndex = true + } else { + paramStr += ',' + params[j] + } + } + } + } else { + funArgs.push(param) + } + } + } } catch (e) { callback('Error encoding arguments: ' + e) return diff --git a/remix-lib/test/txFormat.js b/remix-lib/test/txFormat.js index b75b9acab4..dc00be055c 100644 --- a/remix-lib/test/txFormat.js +++ b/remix-lib/test/txFormat.js @@ -35,8 +35,12 @@ tape('ContractParameters - (TxFormat.buildData) - format input parameters', func }) function testWithInput (st, params, expected) { + console.log('params-----', params) txFormat.buildData('uintContractTest', context.contract, context.output.contracts, true, context.contract.abi[0], params, (error, data) => { - if (error) { return st.fails(error) } + if (error) { + console.log('------', error) + return st.fails(error) + } console.log(data) if (!data.dataHex.endsWith(expected)) { st.fail(`result of buildData ${data.dataHex} should end with ${expected} . `) diff --git a/remix-analyzer/tasks.todo b/tasks.todo similarity index 100% rename from remix-analyzer/tasks.todo rename to tasks.todo