web3j不支持多个索引事件字段?

时间:2018-02-05 19:48:42

标签: events ethereum solidity smartcontracts

我与以太币智能合约有功能:

event onPledged(uint indexed featureKey, uint date, address backer, uint256 amount);
...
function pledge(uint featureKey) public
    payable
    withState(featureKey, State.Funding)
{
    ...

    // event
    onPledged(featureKey, now, backer, pledgeAmount);

    ...
}

我正在使用java测试(使用web3j和web3j-maven-plugin生成智能合约java包装器)来调用检查事件的pledge()

    // pledge
    logger.info("Pledging by backer ...");

    TransactionReceipt pledgeReceipt = pledgerContract.pledge(featureKey, fixedPledgeAmount).send();
    List<AppetissimoContract.OnPledgedEventResponse> pledgedEvents = minerContract.getOnPledgedEvents(pledgeReceipt);
    assertEquals(1, pledgedEvents.size()); // true

如果我将支持者事件字段更改为indexed,则测试开始失败:

event onPledged(uint indexed featureKey, uint date, address indexed backer, uint256 amount);

现在它失败了,因为没有事件(0):

assertEquals(1, pledgedEvents.size()); // false, size() is 0

在可靠性docs中写道,最多3个字段可以是indexed

> Up to three parameters can receive the attribute indexed which will cause the respective arguments to be searched for: It is possible to filter for specific values of indexed arguments in the user interface.

问题是web3j吗?使用indexed属性是否需要更多气体(因此达到气体极限可能是共振)?

1 个答案:

答案 0 :(得分:1)

这是一个与web3j相关的杰出bug。现在你必须在非索引参数之前订购所有索引参数来解决这个问题。