0

This is the smart contract

    pragma solidity ^0.5.0;

    pragma experimental ABIEncoderV2;
    import "./sharedLib.sol";
    import "./clientSC.sol";
    import "./projetSC.sol";


    contract CrowdFactory{

    uint nbrProjetTotal;

    using sharedLib for sharedLib.Client ; 
    using sharedLib for sharedLib.Projet;


//----------------------mapping--------------------   

     mapping(address => ClientSC) public usersinfo;  // contient les 
    donn�es des utilisateurs 
     mapping (uint=> projetSC)public projectsinfo; // contient les donn�es 
  des projets 
    //----------------------tableau d'addresse --------------------   

    address[] public users; // contient les addresse des utilisateurs 
 (wallet)
    address[] public clients;// contient les addresse des contract cr�es 
    address[] public Projects; // contient les addresses des 
      crowdfunding.dapp.crowdfundingdapp.contracts des projet cr�es

      //----------------------Constructeur   --------------------   
     constructor ()public {

     }


      //----------------------Modifier  --------------------   


//----------------------event   --------------------   
event registred(address contractAddress, address publickey, uint userId ) ;
event projectAdded(address contractAddress, address porteur, uint pID ) ;
event loggedin(address publickey , uint userId);// to see who's logged in
      //�project added 





            //----------------------verifier l'existance d'un utilisateur 
       -----------------------------------------
    // verifier si l'addresse de l'utilisateur existe 
    function isRegistred (address _userAddress) 
    internal 
    view   
    returns(bool){
           for(uint256 i = 0; i < users.length; i++){
                if(users[i] == _userAddress) return true;
                else         return false;

           }             
    }

   //----------------------Registration----------------------------------- 
     ------

   function Registration (uint _userId,  string memory _mail ,string 
 memory _password)   
   public
   returns (ClientSC newClient )
     {   require (!isRegistred(msg.sender));
                ClientSC newClient = new ClientSC  ( _userId, _mail , _password);
                usersinfo[msg.sender]= newClient;
                users.push(msg.sender);
                clients.push(address (newClient));
                emit registred(address(newClient),msg.sender, _userId);
                return (newClient) ;
   } 


    function appNewProject (address adr) 
    public
    returns(bool)
    {
     projetSC Project = projetSC(adr);
     if (Project.getProjectState () ==sharedLib.ProjectStatus.Waiting)
     {
         if(Project.getProjectDateFin() <= Project.getProjectDateDebut())
           {  Project.setProjectState(sharedLib.ProjectStatus.Refused);
              return false;

           }else 
           {
            Project.setProjectState(sharedLib.ProjectStatus.Active);
            Projects.push(Project.getProjectContractAddress());        
            nbrProjetTotal =Projects.length;
            projectsinfo[nbrProjetTotal]=Project;

            return true;

         } 
      }

    } 


    function getProject(address adr) public view returns(uint, address){
         projetSC Project = projetSC(adr);
         return (Project.getProjectDateFin (), Project.getProjectContractAddress());
    }







}

This is the generated code

    package contracts;

    import io.reactivex.Flowable;
    import java.math.BigInteger;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Collections;
    import java.util.List;
    import java.util.concurrent.Callable;
    import org.web3j.abi.EventEncoder;
    import org.web3j.abi.TypeReference;
    import org.web3j.abi.datatypes.Address;
    import org.web3j.abi.datatypes.Event;
    import org.web3j.abi.datatypes.Function;
    import org.web3j.abi.datatypes.Type;
    import org.web3j.abi.datatypes.generated.Uint256;
    import org.web3j.crypto.Credentials;
    import org.web3j.protocol.Web3j;
    import org.web3j.protocol.core.DefaultBlockParameter;
    import org.web3j.protocol.core.RemoteCall;
    import org.web3j.protocol.core.methods.request.EthFilter;
    import org.web3j.protocol.core.methods.response.Log;
    import org.web3j.protocol.core.methods.response.TransactionReceipt;
    import org.web3j.tuples.generated.Tuple2;
    import org.web3j.tx.Contract;
    import org.web3j.tx.TransactionManager;
    import org.web3j.tx.gas.ContractGasProvider;

/**
 * <p>Auto generated code.
 * <p><strong>Do not modify!</strong>
 * <p>Please use the <a href="https://docs.web3j.io/command_line.html">web3j command line tools</a>,
 * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the 
 * <a href="https://github.com/web3j/web3j/tree/master/codegen">codegen module</a> to update.
 *
 * <p>Generated with web3j version 4.3.0.
 */
public class CrowdFactory extends Contract {
    private static final String BINARY = "6080610610a4c5..";

    public static final String FUNC_PROJECTSINFO = "projectsinfo";

    public static final String FUNC_PROJECTS = "Projects";

    public static final String FUNC_USERS = "users";

    public static final String FUNC_USERSINFO = "usersinfo";

    public static final String FUNC_REGISTRATION = "Registration";

    public static final String FUNC_APPNEWPROJECT = "appNewProject";

    public static final String FUNC_CLIENTS = "clients";

    public static final String FUNC_GETPROJECT = "getProject";

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

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

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

    @Deprecated
    protected CrowdFactory(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    protected CrowdFactory(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
    }

    @Deprecated
    protected CrowdFactory(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    protected CrowdFactory(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public RemoteCall<String> projectsinfo(BigInteger param0) {
        final Function function = new Function(FUNC_PROJECTSINFO, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(param0)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<String> Projects(BigInteger param0) {
        final Function function = new Function(FUNC_PROJECTS, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(param0)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<String> users(BigInteger param0) {
        final Function function = new Function(FUNC_USERS, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(param0)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<String> usersinfo(String param0) {
        final Function function = new Function(FUNC_USERSINFO, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(param0)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<TransactionReceipt> Registration(BigInteger _userId, String _mail, String _password) {
        final Function function = new Function(
                FUNC_REGISTRATION, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_userId), 
                new org.web3j.abi.datatypes.Utf8String(_mail), 
                new org.web3j.abi.datatypes.Utf8String(_password)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteCall<TransactionReceipt> appNewProject(String adr) {
        final Function function = new Function(
                FUNC_APPNEWPROJECT, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(adr)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteCall<String> clients(BigInteger param0) {
        final Function function = new Function(FUNC_CLIENTS, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(param0)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<Tuple2<BigInteger, String>> getProject(String adr) {
        final Function function = new Function(FUNC_GETPROJECT, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(adr)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Address>() {}));
        return new RemoteCall<Tuple2<BigInteger, String>>(
                new Callable<Tuple2<BigInteger, String>>() {
                    @Override
                    public Tuple2<BigInteger, String> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple2<BigInteger, String>(
                                (BigInteger) results.get(0).getValue(), 
                                (String) results.get(1).getValue());
                    }
                });
    }

    public List<RegistredEventResponse> getRegistredEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(REGISTRED_EVENT, transactionReceipt);
        ArrayList<RegistredEventResponse> responses = new ArrayList<RegistredEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            RegistredEventResponse typedResponse = new RegistredEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.contractAddress = (String) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.publickey = (String) eventValues.getNonIndexedValues().get(1).getValue();
            typedResponse.userId = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Flowable<RegistredEventResponse> registredEventFlowable(EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, RegistredEventResponse>() {
            @Override
            public RegistredEventResponse apply(Log log) {
                Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(REGISTRED_EVENT, log);
                RegistredEventResponse typedResponse = new RegistredEventResponse();
                typedResponse.log = log;
                typedResponse.contractAddress = (String) eventValues.getNonIndexedValues().get(0).getValue();
                typedResponse.publickey = (String) eventValues.getNonIndexedValues().get(1).getValue();
                typedResponse.userId = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
                return typedResponse;
            }
        });
    }

    public Flowable<RegistredEventResponse> registredEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(REGISTRED_EVENT));
        return registredEventFlowable(filter);
    }

    public List<ProjectAddedEventResponse> getProjectAddedEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(PROJECTADDED_EVENT, transactionReceipt);
        ArrayList<ProjectAddedEventResponse> responses = new ArrayList<ProjectAddedEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            ProjectAddedEventResponse typedResponse = new ProjectAddedEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.contractAddress = (String) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.porteur = (String) eventValues.getNonIndexedValues().get(1).getValue();
            typedResponse.pID = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Flowable<ProjectAddedEventResponse> projectAddedEventFlowable(EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, ProjectAddedEventResponse>() {
            @Override
            public ProjectAddedEventResponse apply(Log log) {
                Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(PROJECTADDED_EVENT, log);
                ProjectAddedEventResponse typedResponse = new ProjectAddedEventResponse();
                typedResponse.log = log;
                typedResponse.contractAddress = (String) eventValues.getNonIndexedValues().get(0).getValue();
                typedResponse.porteur = (String) eventValues.getNonIndexedValues().get(1).getValue();
                typedResponse.pID = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
                return typedResponse;
            }
        });
    }

    public Flowable<ProjectAddedEventResponse> projectAddedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(PROJECTADDED_EVENT));
        return projectAddedEventFlowable(filter);
    }

    public List<LoggedinEventResponse> getLoggedinEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(LOGGEDIN_EVENT, transactionReceipt);
        ArrayList<LoggedinEventResponse> responses = new ArrayList<LoggedinEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            LoggedinEventResponse typedResponse = new LoggedinEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.publickey = (String) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.userId = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Flowable<LoggedinEventResponse> loggedinEventFlowable(EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, LoggedinEventResponse>() {
            @Override
            public LoggedinEventResponse apply(Log log) {
                Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(LOGGEDIN_EVENT, log);
                LoggedinEventResponse typedResponse = new LoggedinEventResponse();
                typedResponse.log = log;
                typedResponse.publickey = (String) eventValues.getNonIndexedValues().get(0).getValue();
                typedResponse.userId = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
                return typedResponse;
            }
        });
    }

    public Flowable<LoggedinEventResponse> loggedinEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(LOGGEDIN_EVENT));
        return loggedinEventFlowable(filter);
    }

    @Deprecated
    public static CrowdFactory load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return new CrowdFactory(contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    @Deprecated
    public static CrowdFactory load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new CrowdFactory(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    public static CrowdFactory load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        return new CrowdFactory(contractAddress, web3j, credentials, contractGasProvider);
    }

    public static CrowdFactory load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return new CrowdFactory(contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public static RemoteCall<CrowdFactory> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        return deployRemoteCall(CrowdFactory.class, web3j, credentials, contractGasProvider, BINARY, "");
    }

    public static RemoteCall<CrowdFactory> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return deployRemoteCall(CrowdFactory.class, web3j, transactionManager, contractGasProvider, BINARY, "");
    }

    @Deprecated
    public static RemoteCall<CrowdFactory> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(CrowdFactory.class, web3j, credentials, gasPrice, gasLimit, BINARY, "");
    }

    @Deprecated
    public static RemoteCall<CrowdFactory> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(CrowdFactory.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "");
    }

    public static class RegistredEventResponse {
        public Log log;

        public String contractAddress;

        public String publickey;

        public BigInteger userId;
    }

    public static class ProjectAddedEventResponse {
        public Log log;

        public String contractAddress;

        public String porteur;

        public BigInteger pID;
    }

    public static class LoggedinEventResponse {
        public Log log;

        public String publickey;

        public BigInteger userId;
    }
}
  • it was a problem with the web3j version , now it is resolved – Nour Mhamdi Jul 31 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.