tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
440 stars 277 forks source link

transactionBuilder.js对address[][]参数编码有问题 #433

Closed qfengthree closed 10 months ago

qfengthree commented 1 year ago

src/lib/transactionBuilder.js中对address[][]参数编码有问题,导致返回params为空。 let params = [ { type: 'string[][]', value: poolVersion, }, { type: 'uint256[][]', value: versionLen, }, { type: 'address[][]', value: path, }, { type: 'uint256[]', value: amountIn, }, ]; tronWeb.transactionBuilder.triggerConstantContract(contractAddress, methodId, options, params, issuerAddress)方式构建的params参数有问题。

建议修改方案(增加address[][]判断):

if (type === 'address') value = toHex(value).replace(ADDRESS_PREFIX_REGEX, '0x'); else if (type == 'address[]') value = value.map((v) => v.replace(ADDRESS_PREFIX_REGEX, '0x')); else if (type == 'address[][]') { value = value.map((v1) => v1 = v1.map((v) => v.replace(ADDRESS_PREFIX_REGEX, '0x'))); }

start940315 commented 1 year ago

It is now not support multi-dimension address array but we'll record it and will fix it in the next version.

start940315 commented 10 months ago

Fixed in TronWeb v6.0.0-beta.0. Welcome to try.