static void Main(string[] args)
        {
            BlockPassClientFactory factory = new BlockPassClientFactory();
            var settings = new BlockPassClientSettings()
            {
                ApiKey     = "",
                ServiceUrl = "https://activation-sandbox.blockpass.org"
            };
            var client = factory.CreateNew(settings, false);

            var address = new EthAddressRequest()
            {
                Address     = "0x7ffe9d7f2864b6ab1d781dfa819e3cc4366a7cdf",
                AddressType = "eth"
            };

            var response = client.WhitelistAddressAsync(address).Result;

            System.Console.ReadLine();
        }
Example #2
0
        public static void RegisterServices(this IServiceCollection Services)
        {
            //Uses HttpClient Inside -> singleton
            Services.AddSingleton <ILykkeSigningAPI>((provider) =>
            {
                var baseSettings            = provider.GetService <IBaseSettings>();
                var apiKey                  = baseSettings.SigningServiceApiKey;
                ApiKeyHandler apiKeyHandler = new ApiKeyHandler(apiKey);
                var lykkeSigningApi         = new LykkeSigningAPI(new Uri(provider.GetService <IBaseSettings>().SignatureProviderUrl
                                                                          , UriKind.Absolute), apiKeyHandler);

                return(lykkeSigningApi);
            });

            Services.AddSingleton <IEthereumSamuraiAPI>((provider) =>
            {
                var ethereumSamuraiApi = new EthereumSamuraiAPI(new Uri(provider.GetService <IBaseSettings>().EthereumSamuraiUrl
                                                                        , UriKind.Absolute));

                return(ethereumSamuraiApi);
            });

            Services.AddSingleton <Web3>((provider) =>
            {
                var baseSettings = provider.GetService <IBaseSettings>();
                var web3         = new Web3(baseSettings.EthereumUrl);

                return(web3);
            });

            Services.AddSingleton <IWeb3>((provider) =>
            {
                var web3 = provider.GetService <Web3>();

                return(new Web3Decorator(web3));
            });


            Services.AddSingleton <ITransactionManager>(provider =>
            {
                var baseSettings       = provider.GetService <IBaseSettings>();
                var web3               = provider.GetService <Web3>();
                var signatureApi       = provider.GetService <ILykkeSigningAPI>();
                var nonceCalculator    = provider.GetService <INonceCalculator>();
                var transactionRouter  = provider.GetService <ITransactionRouter>();
                var gasPriceRepository = provider.GetService <IGasPriceRepository>();

                var transactionManager = new LykkeSignedTransactionManager(baseSettings, nonceCalculator, signatureApi, transactionRouter, web3, gasPriceRepository);

                web3.TransactionManager = transactionManager;
                web3.Client.OverridingRequestInterceptor = new SignatureInterceptor(transactionManager);

                return(transactionManager);
            });

            Services.AddSingleton <IAssetsService>((provider) =>
            {
                var settings = provider.GetService <AppSettings>();

                return(new AssetsService(new Uri(settings.Assets.ServiceUrl)));
            });

            Services.AddSingleton <IBlockPassClient>((provider) =>
            {
                var settings = provider.GetService <BlockPassClientSettings>();
                BlockPassClientFactory factory = new BlockPassClientFactory();
                var client = factory.CreateNew(settings, false);

                return(client);
            });
        }