protected override async Task <GetProductResponse> HandleCoreAsync(GetProductRequest request)
        {
            var abi = await CachedABIManager.GetAbiAsync(request.ProductAddress);

            var insuranceProductContract = new InsuranceProduct(request.ProductAddress, abi);

            var product = await insuranceProductContract.GetProductAsync();

            return(new GetProductResponse
            {
                Address = request.ProductAddress,
                PremiumCalcultator = product.PremiumCalcultator,
                InvestorsPool = product.InvestorsPool,
                StartDateUtc = product.StartDateUtc,
                EndDateUtc = product.EndDateUtc,
                Title = product.Title,
                Description = product.Description,
                PolicyTermInSeconds = product.PolicyTermInSeconds,
                BasePremium = product.BasePremium,
                Payout = product.Payout,
                Loading = product.Loading,
                PoliciesLimit = product.PoliciesLimit,
                ProductPoolLimit = product.ProductPoolLimit,
                CreatedUtc = product.CreatedUtc
            });
        }
        public static async Task <IInsuranceProduct> CreateProductFromAddressAsync(string productAddress)
        {
            var productAbi = await CachedABIManager.GetAbiAsync(productAddress);

            var insuranceProductContract = new InsuranceProduct(productAddress, productAbi);

            return(insuranceProductContract);
        }
        protected override async Task <GetPolicyResponse> HandleCoreAsync(BaseInsuranceRequest request)
        {
            var response = new GetPolicyResponse();

            var abi = await CachedABIManager.GetAbiAsync(request.ProductAddress);

            var insuranceProductContract = new InsuranceProduct(request.ProductAddress, abi);

            response.Policy = await insuranceProductContract.GetPolicyAsync(request.PolicyId);

            return(response);
        }
        public static async Task <PremiumCalculator> CreatePremiumCalculatorFromAddressAsync(string productAddress)
        {
            var productAbi = await CachedABIManager.GetAbiAsync(productAddress);

            var insuranceProductContract = new InsuranceProduct(productAddress, productAbi);

            var premiumCalculatorAddress = await insuranceProductContract.GetPremiumCalculatorAddressAsync();

            var premiumCalculatorAbi = await CachedABIManager.GetAbiAsync(premiumCalculatorAddress);

            var premiumCalculatorContract = new PremiumCalculator(premiumCalculatorAddress, premiumCalculatorAbi);

            return(premiumCalculatorContract);
        }
Exemplo n.º 5
0
        protected override async Task <GetProductStatsResponse> HandleCoreAsync(GetProductStatsRequest request)
        {
            var abi = await CachedABIManager.GetAbiAsync(request.ProductAddress);

            var insuranceProductContract = new InsuranceProduct(request.ProductAddress, abi);


            var stats = await insuranceProductContract.GetProductStatsAsync();

            return(new GetProductStatsResponse
            {
                Paused = stats.Paused,
                PoliciesLength = stats.PoliciesLength,
                ProductTokensPool = stats.TokenBalance,
                PayoutsCount = stats.PayoutsCount,
                TotalCalculatedPayouts = stats.TotalCalculatedPayouts,
                TotalPayouts = stats.TotalPayouts
            });
        }