package monnethic.mobile.blockchain.client; import org.hyperledger.fabric.sdk.Channel; import org.hyperledger.fabric.sdk.HFClient; import org.hyperledger.fabric.sdk.exception.CryptoException; import org.hyperledger.fabric.sdk.exception.InvalidArgumentException; import org.hyperledger.fabric.sdk.security.CryptoSuite; import java.lang.reflect.InvocationTargetException; import monnethic.mobile.blockchain.participant.UserContext; public class FabriClientWrapper { private HFClient hfClient; public HFClient getHfClient() { return hfClient; } public FabriClientWrapper(UserContext userContext) throws CryptoException, InvalidArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException { CryptoSuite cryptoSuite = CryptoSuite.Factory.getCryptoSuite(); hfClient = HFClient.createNewInstance(); hfClient.setCryptoSuite(cryptoSuite); hfClient.setUserContext(userContext); } public ChannelClientWrapper createChannelClient(String name) throws InvalidArgumentException { Channel channel = hfClient.newChannel(name); ChannelClientWrapper client = new ChannelClientWrapper(name, channel, this); return client; } }