Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sol合约转换java 发生类型转换错误 #801

Open
userInner opened this issue Jul 6, 2023 · 4 comments
Open

sol合约转换java 发生类型转换错误 #801

userInner opened this issue Jul 6, 2023 · 4 comments
Labels
codec resolved The issue has been resolved v2.x

Comments

@userInner
Copy link

编译时发生:

/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:128: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:129: 错误: 对于Uint8(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint8(receiptType)),
                                ^
    构造器 Uint8.Uint8(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint8.Uint8(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:146: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:147: 错误: 对于Uint8(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint8(receiptType)),
                                ^
    构造器 Uint8.Uint8(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint8.Uint8(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:160: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:161: 错误: 对于Uint8(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint8(receiptType)),
                                ^
    构造器 Uint8.Uint8(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint8.Uint8(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:215: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(credit)),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:228: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(credit)),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:240: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(credit)),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:329: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:330: 错误: 对于Uint8(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint8(receiptType)),
                                ^
    构造器 Uint8.Uint8(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint8.Uint8(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:347: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:348: 错误: 对于Uint8(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint8(receiptType)),
                                ^
    构造器 Uint8.Uint8(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint8.Uint8(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:361: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:362: 错误: 对于Uint8(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint8(receiptType)),
                                ^
    构造器 Uint8.Uint8(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint8.Uint8(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:448: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:449: 错误: 对于Uint8(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint8(receiptType)),
                                ^
    构造器 Uint8.Uint8(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint8.Uint8(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:466: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:467: 错误: 对于Uint8(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint8(receiptType)),
                                ^
    构造器 Uint8.Uint8(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint8.Uint8(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:480: 错误: 对于Uint256(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(amount),
                                ^
    构造器 Uint256.Uint256(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint256.Uint256(long)不适用
      (参数不匹配; String无法转换为long)
/java-sdk-demo/src/main/java/org/fisco/bcos/sdk/demo/contract/SupplyChainFin.java:481: 错误: 对于Uint8(String), 找不到合适的构造器
                                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint8(receiptType)),
                                ^
    构造器 Uint8.Uint8(BigInteger)不适用
      (参数不匹配; String无法转换为BigInteger)
    构造器 Uint8.Uint8(long)不适用
      (参数不匹配; String无法转换为long)
21 个错误

解决方案:手动替换类型

@kyonRay
Copy link
Member

kyonRay commented Jul 7, 2023

是使用2.0的什么版本?能否提供合约的abi文件?

@userInner
Copy link
Author

[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"banks","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"senderAddress","type":"address"},{"name":"accepterAddress","type":"address"},{"name":"amount","type":"uint256"},{"name":"receiptType","type":"uint8"}],"name":"companyToCompanyReceipt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"companies","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"name","type":"string"},{"name":"bankAddress","type":"address"},{"name":"credit","type":"uint256"}],"name":"addBank","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"name","type":"string"},{"name":"companyAddress","type":"address"}],"name":"addCompany","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"senderAddress","type":"address"},{"name":"accepterAddress","type":"address"},{"name":"amount","type":"uint256"},{"name":"receiptType","type":"uint8"}],"name":"companyToBankReceipt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"companyAddress","type":"address"}],"name":"getCompany","outputs":[{"name":"","type":"string"},{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256[]"},{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getAllBankAddress","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"receiptIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"senderAddress","type":"address"},{"name":"accepterAddress","type":"address"},{"name":"amount","type":"uint256"},{"name":"receiptType","type":"uint8"}],"name":"bankToCompanyReceipt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"bankAddress","type":"address"}],"name":"getBank","outputs":[{"name":"","type":"string"},{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256[]"},{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"superviosrIns","outputs":[{"name":"supervisorName","type":"string"},{"name":"supervisorAddress","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"index","type":"uint256"}],"name":"getReceipt","outputs":[{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"uint8"},{"name":"","type":"uint8"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getAllCompanyAddress","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"name","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

版本:2.0,位于java-sdk-demo main-2.0 分支
https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/tutorial/stress_testing.html

@kyonRay
Copy link
Member

kyonRay commented Jul 10, 2023

[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"banks","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"senderAddress","type":"address"},{"name":"accepterAddress","type":"address"},{"name":"amount","type":"uint256"},{"name":"receiptType","type":"uint8"}],"name":"companyToCompanyReceipt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"companies","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"name","type":"string"},{"name":"bankAddress","type":"address"},{"name":"credit","type":"uint256"}],"name":"addBank","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"name","type":"string"},{"name":"companyAddress","type":"address"}],"name":"addCompany","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"senderAddress","type":"address"},{"name":"accepterAddress","type":"address"},{"name":"amount","type":"uint256"},{"name":"receiptType","type":"uint8"}],"name":"companyToBankReceipt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"companyAddress","type":"address"}],"name":"getCompany","outputs":[{"name":"","type":"string"},{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256[]"},{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getAllBankAddress","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"receiptIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"senderAddress","type":"address"},{"name":"accepterAddress","type":"address"},{"name":"amount","type":"uint256"},{"name":"receiptType","type":"uint8"}],"name":"bankToCompanyReceipt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"bankAddress","type":"address"}],"name":"getBank","outputs":[{"name":"","type":"string"},{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256[]"},{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"superviosrIns","outputs":[{"name":"supervisorName","type":"string"},{"name":"supervisorAddress","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"index","type":"uint256"}],"name":"getReceipt","outputs":[{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"uint8"},{"name":"","type":"uint8"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getAllCompanyAddress","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"name","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

版本:2.0,位于java-sdk-demo main-2.0 分支 https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/tutorial/stress_testing.html

收到,下一个2.x版本将修复这个错误。

@kyonRay kyonRay added the bug Something isn't working label Jul 10, 2023
@kyonRay
Copy link
Member

kyonRay commented Aug 10, 2023

FISCO-BCOS/code-generator#20
这个PR解决了这个问题

@kyonRay kyonRay added resolved The issue has been resolved and removed bug Something isn't working labels Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codec resolved The issue has been resolved v2.x
Projects
None yet
Development

No branches or pull requests

2 participants