예제 #1
0
        public static async Task <HeleusClientResponse> RequestRevenue(int chainId, AccountRevenueInfo accountRevenue)
        {
            HeleusClientResponse result = null;

            if (!HasCoreAccount)
            {
                result = new HeleusClientResponse(HeleusClientResultTypes.NoCoreAccount);
                goto end;
            }

            if (_busy)
            {
                result = new HeleusClientResponse(HeleusClientResultTypes.Busy);
                goto end;
            }
            _busy = true;

            if (!await Client.SetTargetChain(chainId))
            {
                result = new HeleusClientResponse(HeleusClientResultTypes.EndpointConnectionError);
                goto end;
            }

            result = await Client.RequestRevenue(chainId, accountRevenue);

            if (result.TransactionResult == TransactionResultTypes.Ok)
            {
                UIApp.Run(() => UpdateCoreAccountBalance());
            }

end:

            await UIApp.PubSub.PublishAsync(new RequestRevenueEvent(result, accountRevenue));

            if (result.ResultType != HeleusClientResultTypes.Busy)
            {
                _busy = false;
            }

            return(result);
        }
예제 #2
0
        protected override async Task QueryDoneAsync(int chainId, ChainInfo chainInfo)
        {
            _revenueInfo = null;
            if (chainInfo != null)
            {
                var endPoints = chainInfo.GetPublicEndpoints();
                if (endPoints.Count > 0)
                {
                    var client   = new ClientBase(new Uri(endPoints[0]), chainId);
                    var download = (await client.DownloadRevenueInfo(chainId, WalletApp.CurrentAccountId));
                    var data     = download.Data;
                    _revenueInfo = data?.Item;
                    if (_revenueInfo == null)
                    {
                        await ErrorAsync("QueryRevenueFailed");
                    }
                }
            }

            _revenueView.Update(_revenueInfo);
        }
예제 #3
0
 public RequestRevenueEvent(HeleusClientResponse response, AccountRevenueInfo revenueInfo)
 {
     Response    = response;
     RevenueInfo = revenueInfo;
 }