Skip to content

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

@qfengthree

Description

@qfengthree

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')));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions