FISCO-BCOS / solcJ

a jar for the solidity compiler
Apache License 2.0
7 stars 10 forks source link

使用solcJ 0.6.10.0版本的库编译合约报错 #33

Closed 13813385093 closed 1 year ago

13813385093 commented 1 year ago

maven引入依赖:

org.fisco-bcos solcJ 0.6.10.0

尝试通过SolidityCompiler.Result res = SolidityCompiler.compile(byte[] source, boolean sm, boolean combinedJson, Option... options)方法编译智能合约。 入参为SolidityCompiler.Result res = SolidityCompiler.compile(contractSourceByteArr, true, true, ABI, BIN, INTERFACE, METADATA); 其中contractSourceByteArr为合约的byte[],合约在前置服务提供的界面中可以编译成功,通过上面的方法进行编译报错信息为:No input files given. If you wish to use the standard input please specify "-" explicitly.

无法定位错误的原因。

pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;

contract Ticket {
    struct TicketEntity {
        bool isInit;
        string id;
        bool isCancel;
        bool isArchive;
        string state;
        uint256 createTime;
        uint256 updateTime;
        string[] fieldName;
        string[] fieldValue;
        string[] orderIds;
    }

    struct OrderEntity {
        bool isInit;
        bool isCancel;
        string state;
        uint256 createTime;
        uint256 updateTime;
        string[] fieldName;
        string[] fieldValue;
        string id;
    }

    mapping(string=>TicketEntity) private ticketEntities;
    mapping(string=>OrderEntity) private  orderEntities;
    string[] private ticketEntityKeys;

    function putTicketEntity(string memory ticketId, TicketEntity memory entity) public {
        entity.isInit = true;
        TicketEntity memory ticketEntity;
        for(uint i = 0; i < ticketEntityKeys.length; i++) {
            if(keccak256(bytes(ticketEntityKeys[i])) == keccak256(bytes(ticketId))) {
                 ticketEntity = ticketEntities[ticketId];
            }
        }
        if(!ticketEntity.isInit) {
            ticketEntityKeys.push(ticketId);
        }

        ticketEntities[ticketId] = entity;
    }

    function putOrderEntity(string memory ticketId, string memory orderId, OrderEntity memory entity) public {
        entity.isInit = true;
        TicketEntity memory ticketEntity;
        for(uint i = 0; i < ticketEntityKeys.length; i++) {
            if(keccak256(bytes(ticketEntityKeys[i])) == keccak256(bytes(ticketId))) {
                ticketEntity = ticketEntities[ticketId];
            }
        }
        if(!ticketEntity.isInit) {
            revert("Ticket inexistence");
        }
        OrderEntity memory orderEntity;
        for(uint i = 0; i < ticketEntity.orderIds.length; i++) {
            if(keccak256(bytes(ticketEntity.orderIds[i])) == keccak256(bytes(orderId))) {
                orderEntity = orderEntities[orderId];
            }
        }
        if(!orderEntity.isInit) {
            ticketEntities[ticketId].orderIds.push(orderId);
        }
        orderEntities[orderId] = entity;
    }

    function getTicketEntity(string memory ticketId) public view returns(TicketEntity memory, OrderEntity[] memory) {
        TicketEntity memory ticket;

        for(uint i = 0; i < ticketEntityKeys.length; i++) {
            if(keccak256(bytes(ticketEntityKeys[i])) == keccak256(bytes(ticketId))) {
                ticket = ticketEntities[ticketId];
            }
        }
        if(!ticket.isInit) {
            revert("Ticket inexistence");
        }
        OrderEntity[] memory orders = new OrderEntity[](ticket.orderIds.length);
        for(uint i = 0; i < ticket.orderIds.length; i++) {
            orders[i] = orderEntities[ticket.orderIds[i]];
        }
        return (ticket, orders);
    }

}

上面是我的智能合约。

13813385093 commented 1 year ago

好像是我弄错了,这个问题换了一个环境就无法复现了