Skip to content

Commit 525d899

Browse files
authored
Add Invest v2. No business logic. (block-core#640)
1 parent 4c4c3bc commit 525d899

File tree

69 files changed

+1400
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1400
-212
lines changed

src/Angor/Avalonia/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ Generated_Code/
257257
# to a newer Visual Studio version. Backup files are not needed,
258258
# because we have git ;-)
259259
_UpgradeReport_Files/
260-
Backup*/
261260
UpgradeLog*.XML
262261
UpgradeLog*.htm
263262
ServiceFabricBackup/

src/Angor/Avalonia/AngorApp.Model/Contracts/Wallet/IWallet.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public interface IWallet
1414
IAmountUI ReservedBalance { get; }
1515
Result IsAddressValid(string address);
1616
WalletId Id { get; }
17+
public string Name { get; }
1718
IEnhancedCommand Send { get; }
1819
public IEnhancedCommand<Result<string>> GetReceiveAddress { get; }
1920
public Task<Result<string>> GenerateReceiveAddress();

src/Angor/Avalonia/AngorApp.Model/Wallet/Simple/SimpleWallet.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ private RefreshableCollection<IBroadcastedTransaction, string> CreateTransaction
8888
}
8989

9090
public IObservable<string> ReceiveAddress { get; }
91+
public string Name { get; } = "Default";
9192
public IEnhancedCommand Send { get; }
9293
public IEnhancedCommand<Result<string>> GetReceiveAddress { get; }
9394
public IEnhancedCommand<Result<IEnumerable<IBroadcastedTransaction>>> Load { get; }

src/Angor/Avalonia/AngorApp/Composition/Registrations/ViewModels/ViewModels.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
using ShellViewModel = AngorApp.UI.Shell.ShellViewModel;
1717
using WalletSectionViewModel = AngorApp.UI.Sections.Wallet.Main.WalletSectionViewModel;
1818
using Angor.Sdk.Funding.Projects.Dtos;
19+
using AngorApp.UI.Flows.InvestV2;
20+
21+
using AngorApp.UI.Flows.InvestV2.PaymentSelector;
1922

2023
namespace AngorApp.Composition.Registrations.ViewModels;
2124

@@ -37,6 +40,8 @@ public static IServiceCollection AddViewModels(this IServiceCollection services)
3740
.AddTransient<IFounderSectionViewModel, FounderSectionViewModel>()
3841
.AddTransient<ISettingsSectionViewModel, SettingsSectionViewModel>()
3942
.AddScoped<IPenaltiesViewModel, PenaltiesViewModel>()
43+
.AddScoped<IInvestViewModel, InvestViewModel>()
44+
.AddScoped<IPaymentSelectorViewModel, PaymentSelectorViewModel>()
4045
.AddScoped<IRecoverViewModel, RecoverViewModel>()
4146
.AddSingleton<IShellViewModel, ShellViewModel>();
4247
}

src/Angor/Avalonia/AngorApp/Core/Factories/IProjectInvestCommandFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ namespace AngorApp.Core.Factories;
22

33
public interface IProjectInvestCommandFactory
44
{
5-
IEnhancedCommand<Result<Maybe<Unit>>> Create(FullProject project, bool isInsideInvestmentPeriod);
5+
IEnhancedCommand<Result<Unit>> Create(FullProject project, bool isInsideInvestmentPeriod);
66
}
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using AngorApp.UI.Flows.Invest;
2+
using AngorApp.UI.Flows.InvestV2;
3+
using Zafiro.UI.Navigation;
24

35
namespace AngorApp.Core.Factories;
46

@@ -7,28 +9,24 @@ public class ProjectInvestCommandFactory : IProjectInvestCommandFactory
79
private readonly InvestFlow investFlow;
810
private readonly UIServices uiServices;
911
private readonly IWalletContext walletContext;
12+
private readonly INavigator navigator;
1013

1114
public ProjectInvestCommandFactory(
1215
InvestFlow investFlow,
1316
UIServices uiServices,
14-
IWalletContext walletContext)
17+
IWalletContext walletContext, INavigator navigator)
1518
{
1619
this.investFlow = investFlow;
1720
this.uiServices = uiServices;
1821
this.walletContext = walletContext;
22+
this.navigator = navigator;
1923
}
2024

21-
public IEnhancedCommand<Result<Maybe<Unit>>> Create(FullProject project, bool isInsideInvestmentPeriod)
25+
public IEnhancedCommand<Result<Unit>> Create(FullProject project, bool isInsideInvestmentPeriod)
2226
{
2327
var canExecute = Observable.Return(isInsideInvestmentPeriod);
24-
25-
var command = ReactiveCommand.CreateFromTask(
26-
() => walletContext.RequiresWallet(wallet => investFlow.Invest(wallet, project)),
27-
canExecute)
28-
.Enhance();
29-
28+
var command = EnhancedCommand.CreateWithResult(() => navigator.Go<IInvestViewModel>(), canExecute);
3029
command.HandleErrorsWith(uiServices.NotificationService, "Investment failed");
31-
3230
return command;
3331
}
3432
}

src/Angor/Avalonia/AngorApp/UI/Flows/CreateProject/CreateProjectFlow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private SlimWizard<string> CreateWizard(IWallet wallet, ProjectSeedDto projectSe
3838
var wizard = WizardBuilder
3939
.StartWith(() => new CreateProjectViewModel(wallet, projectSeed, uiServices, projectAppService, founderAppService, logger), "Create Project").NextCommand(model => model.Create)
4040
.Then(transactionId => new ProjectCreatedViewModel(transactionId, commands), "Success").Next((_, projectId) => projectId, "Close").Always()
41-
.WithCompletionFinalStep();
41+
.Build(StepKind.Completion);
4242

4343
return wizard;
4444
}

src/Angor/Avalonia/AngorApp/UI/Flows/CreateProject/CreateProjectFlowV2.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private async Task<Result<Maybe<string>>> Create(WalletId walletId, ProjectSeedD
4848
walletId,
4949
seed))
5050
.Then(txId => new SuccessViewModel($"Project {txId} created successfully!"), "Success").Next((_, s) => s, "Finish").Always()
51-
.WithCompletionFinalStep();
51+
.Build(StepKind.Completion);
5252

5353
return await rootWizard.Navigate(navigator);
5454
}
@@ -94,7 +94,7 @@ private SlimWizard<string> CreateInvestmentProjectWizard(WalletId walletId, Proj
9494
seed,
9595
uiServices))
9696
.NextCommand(review => review.DeployCommand)
97-
.WithCommitFinalStep();
97+
.Build(StepKind.Commit);
9898

9999
return wizard;
100100
}
@@ -119,7 +119,7 @@ private SlimWizard<string> CreateFundProjectWizard(WalletId walletId, ProjectSee
119119
seed,
120120
uiServices))
121121
.NextCommand(review => review.DeployCommand)
122-
.WithCommitFinalStep();
122+
.Build(StepKind.Commit);
123123

124124
return wizard;
125125
}

src/Angor/Avalonia/AngorApp/UI/Flows/CreateProject/Wizard/FundProject/Payouts/PayoutsView.axaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<ListBox SelectedItem="{Binding FundProject.PayoutFrequency, Mode=TwoWay}"
4444
SelectionMode="Single"
4545
ItemsSource="{Binding AvailableFrequencies}"
46-
ItemContainerTheme="{StaticResource ButtonizedAccent}"
46+
ItemContainerTheme="{StaticResource ButtonizedAccentListBoxItem}"
4747
Background="Transparent">
4848
<ListBox.ItemsPanel>
4949
<ItemsPanelTemplate>
@@ -66,7 +66,7 @@
6666

6767
<ListBox ItemsSource="{Binding AvailableInstallmentCounts}"
6868
Selection="{Binding FundProject.SelectedInstallments.SelectionModel}"
69-
ItemContainerTheme="{StaticResource ButtonizedAccent}"
69+
ItemContainerTheme="{StaticResource ButtonizedAccentListBoxItem}"
7070
Background="Transparent">
7171
<ListBox.ItemsPanel>
7272
<ItemsPanelTemplate>
@@ -94,7 +94,7 @@
9494
<ListBox SelectedItem="{Binding FundProject.MonthlyPayoutDate, Mode=TwoWay}"
9595
SelectionMode="Multiple"
9696
ItemsSource="{Binding AvailablePayoutDates}"
97-
ItemContainerTheme="{StaticResource ButtonizedAccent}"
97+
ItemContainerTheme="{StaticResource ButtonizedAccentListBoxItem}"
9898
Background="Transparent">
9999
<ListBox.ItemsPanel>
100100
<ItemsPanelTemplate>
@@ -118,7 +118,7 @@
118118
<ListBox SelectedItem="{Binding FundProject.WeeklyPayoutDay, Mode=TwoWay}"
119119
SelectionMode="Single"
120120
ItemsSource="{Binding AvailableDaysOfWeek}"
121-
ItemContainerTheme="{StaticResource ButtonizedAccent}"
121+
ItemContainerTheme="{StaticResource ButtonizedAccentListBoxItem}"
122122
Background="Transparent">
123123
<ListBox.ItemsPanel>
124124
<ItemsPanelTemplate>

src/Angor/Avalonia/AngorApp/UI/Flows/CreateProject/Wizard/InvestmentProject/FundingConfigurationView.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260

261261
<ListBox SelectedValueBinding="{Binding Months}"
262262
SelectedValue="{Binding NewProject.FundingEndDate, Mode=TwoWay, Converter={x:Static controls:AngorConverters.AddMonthsToToday}}"
263-
ItemContainerTheme="{StaticResource ButtonizedAccent}" Background="Transparent">
263+
ItemContainerTheme="{StaticResource ButtonizedAccentListBoxItem}" Background="Transparent">
264264
<ListBox.ItemsSource>
265265
<generic:List x:TypeArguments="model:PeriodOption">
266266
<model:PeriodOption Months="1" Title="1 Month" />

0 commit comments

Comments
 (0)