public static WebWalletState ReduceFreeTokenAction(WebWalletState state, WebWalletFreeTokenResultAction action) =>
 state.With(new {
     stage               = UIStage.FreeToken,
     faucetBalance       = action.faucetBalance,
     ValidReCAPTCHA      = false,
     ServerVerificatiing = false
 });
        public static WebWalletState ReduceSaveSettingsAction(WebWalletState state, WebWalletSaveSettingsAction action)
        {
            var state2 = state.With(new
            {
                stage = UIStage.Main,
            });

            state2.wallet.VoteFor = action.VoteFor;
            return(state2);
        }
        public static WebWalletState ReduceSwapTLYRResultAction(WebWalletState state, WebWalletSwapTLYRResultAction action)
        {
            var stt = state.With(new
            {
                IsLoading = false,
                LastOperationIsSuccess = action.Success,
                Message = action.errMessage
            });

            return(stt);
        }
        public static WebWalletState ReduceLyraSwapResultAction(WebWalletState state, WebWalletTokenSwapResultAction action)
        {
            var stt = state.With(new
            {
                IsLoading = false,
                LastOperationIsSuccess = action.Success,
                Message = action.Success ? "Swapping is succeed!" : "Swapping is failed."
            });

            return(stt);
        }
        public static WebWalletState ReduceSendMeFreeTokenAction(WebWalletState state, WebWalletSendMeFreeTokenResultAction action)
        {
            var stt = state.With(new {
                stage = UIStage.Main,
                LastOperationIsSuccess = action.Success
            });

            if (action.Success)
            {
                stt.freeTokenSent = true;
                stt.freeTokenTimes++;
            }
            return(stt);
        }
        public static WebWalletState RefreshBalanceAction(WebWalletState state, WebWalletResultAction action)
        {
            var bs = "<empty>";

            if (action.wallet == null)
            {
            }
            else
            {
                var bst = action.wallet.GetDisplayBalancesAsync().ContinueWith(a => bs = a.Result);
                bst.Wait();
            }

            return(state.With(new
            {
                IsLoading = false,
                stage = action.stage,
                IsOpening = action.IsOpening,
                wallet = action.wallet,
                balanceString = bs
            }));
        }
 public static WebWalletState ReduceOpenSettingsAction(WebWalletState state, WebWalletSettingsAction action) => state.With(new { stage = UIStage.Settings });
 public static WebWalletState CancelSendAction(WebWalletState state, WebWalletCancelSendAction action) => state.With(new { stage = UIStage.Main });
 public static WebWalletState SendTokenActionHandler(WebWalletState state, WebWalletSendTokenAction action) => state.With(new { IsLoading = true });
 public static WebWalletState ReductLyraSwapHandler(WebWalletState state, WebWalletBeginTokenSwapAction action) => state.With(new { IsLoading = true });
 public static WebWalletState GetTransactionActionHandler(WebWalletState state, WebWalletTransactionsAction action) => state.With(new { IsLoading = true });
 public static WebWalletState ReduceRCServerAction(WebWalletState state, WebWalletReCAPTCHAServerAction action) => state.With(new { ServerVerificatiing = action.ServerVerificatiing });
 public static WebWalletState ReduceRCValidAction(WebWalletState state, WebWalletReCAPTCHAValidAction action) => state.With(new { ValidReCAPTCHA = action.ValidReCAPTCHA });
 public static WebWalletState RestoreWalletActionHandler(WebWalletState state, WebWalletRestoreAction action) => state.With(new { IsLoading = true });
 public static WebWalletState ReductSwapTLYRHandler(WebWalletState state, WebWalletBeginSwapTLYRAction action) => state.With(new { IsLoading = true });
 public static WebWalletState ReduceSwapTLYRAction(WebWalletState state, WebWalletSwapTLYRAction action) => state.With(new { stage = UIStage.SwapTLYR, Message = "" });
 public static WebWalletState ReduceCancelSaveSettingsAction(WebWalletState state, WebWalletCancelSaveSettingsAction action) => state.With(new { stage = UIStage.Main });
 public static WebWalletState RefreshBalanceActionHandler(WebWalletState state, WebWalletRefreshBalanceAction action) => state.With(new { IsLoading = true });
 public static WebWalletState ReduceTransactionsAction(WebWalletState state, WebWalletTransactionsResultAction action) =>
 state.With(new {
     IsLoading = false,
     stage     = UIStage.Transactions,
     txs       = action.transactions
 });
 public static WebWalletState CloseAction(WebWalletState state, WebWalletCloseAction action) => new WebWalletState();
 public static WebWalletState SendAction(WebWalletState state, WebWalletSendAction action) => state.With(new { stage = UIStage.Send });
 public static WebWalletState ReduceLyraSwapAction(WebWalletState state, WebWalletSwapTokenAction action) => state.With(new
 {
     stage   = UIStage.SwapToken,
     Message = ""
 });