web3j 不支持多个索引事件字段?
Multiple indexed event fields are not supported by web3j?
我有以太坊智能合约功能:
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
如果我将 backer 事件字段更改为 indexed
测试开始失败:
event onPledged(uint indexed featureKey, uint date, address indexed backer, uint256 amount);
现在失败了,因为没有事件 (0):
assertEquals(1, pledgedEvents.size()); // false, size() is 0
在 solidity 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
属性是否需要更多气体(因此达到气体限制可能是原因)?
这是 web3j 的杰出 bug。现在您必须在非索引参数之前对所有索引参数进行排序才能解决此问题。
我有以太坊智能合约功能:
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
如果我将 backer 事件字段更改为 indexed
测试开始失败:
event onPledged(uint indexed featureKey, uint date, address indexed backer, uint256 amount);
现在失败了,因为没有事件 (0):
assertEquals(1, pledgedEvents.size()); // false, size() is 0
在 solidity 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
属性是否需要更多气体(因此达到气体限制可能是原因)?
这是 web3j 的杰出 bug。现在您必须在非索引参数之前对所有索引参数进行排序才能解决此问题。