Web3j Android Java Solidity包装器错误

时间:2018-07-28 01:16:27

标签: java ethereum web3-java

尝试使用web3j调用合同中的某些功能。我遵循了坚固性指南,并获得了该合同的.abi和.bin-https://etherscan.io/address/0x9dda40dabd849bbb087dcbcf0c5223ec5ffa0ad7#code。然后使用web3j命令行进行.java文件包装,输出到正确的目录。

一切正常,但以下几行:

public static final Event FUNDSWITHDRAWN_EVENT = new Event("FundsWithdrawn",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Uint256>() {}));
;

public static final Event FUNDSDEPOSITED_EVENT = new Event("FundsDeposited",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Uint256>() {}));
;

public static final Event SERVERADDED_EVENT = new Event("ServerAdded",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
;

public static final Event SERVERREMOVED_EVENT = new Event("ServerRemoved",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
;

public static final Event GAMESTARTED_EVENT = new Event("GameStarted",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<DynamicArray<Address>>() {}));
;

public static final Event GAMEENDED_EVENT = new Event("GameEnded",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}));
;

抛出错误:

Event() in Event cannot be applied to:
Expected Parameters:
Actual Arguments:

name:
String
"ServerAdded"  
indexedParameters:
List<TypeReference<?>>
Arrays...new TypeReference<Uint256>() {})  
nonIndexedParameters:
List<TypeReference<?>>

这两行:

    public static final Event OWNERSHIPRENOUNCED_EVENT = new Event("OwnershipRenounced",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}));
;

public static final Event OWNERSHIPTRANSFERRED_EVENT = new Event("OwnershipTransferred",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}));
;

给出错误:     TypeReference()     不能应用TypeReference中的     至     (布尔值)

我不是合同创建者,但它确实可以在其web3js和metamask实现中正常工作。由于这些事件是针对服务器端的,我在想一件事,我是否甚至需要包含它们? (尽管您稍后会看到它们的引用),但我只是想知道是否使用.bin文件会强迫您不进行更改?无论如何还是新手,感谢任何帮助或指导,谢谢。

1 个答案:

答案 0 :(得分:0)

在我看来,版本似乎有问题,因为Java类的生成存在语法错误。

您所能做的就是尝试手动解决此问题:删除true,然后更改一些代码。

@api.onchange('product_id')
def onchange_product_id(self):
    res = super(PurchaseOrderLine, self).onchange_product_id()
    # your logic here
    for rec in self:
        rec.product_qty = 10  # will trigger _onchange_quantity() on return

    return res

@api.onchange('product_qty', 'product_uom')
def _onchange_quantity(self):
    res = super(PurchaseOrderLine, self)._onchange_quantity()
    # your logic here
    for rec in self:
        rec.price_unit = 1.0

    return res