├── .gitattributes
├── .gitignore
├── LICENSE.md
├── Nethereum.StandardToken.Desktop
├── Designers
│ ├── StandardTokenBalanceOfViewModelDesigner.cs
│ └── StandardTokenTransferViewModelDesigner.cs
├── Nethereum.StandardToken.Desktop.csproj
├── StandardTokenBalanceOfUserControl.xaml
├── StandardTokenBalanceOfUserControl.xaml.cs
├── StandardTokenTransferUserControl.xaml
├── StandardTokenTransferUserControl.xaml.cs
├── StandardTokenUserControl.xaml
└── StandardTokenUserControl.xaml.cs
├── Nethereum.StandardToken.UI
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── Nethereum.StandardToken.UI.csproj
├── SmartContractMessages
│ ├── BalanceOfFunction.cs
│ └── TransferFunction.cs
└── ViewModels
│ ├── StandardTokenBalanceOfViewModel.cs
│ ├── StandardTokenTransferViewModel.cs
│ └── StandardTokenViewModel.cs
├── Nethereum.UI.Desktop.Common
├── ContractAddressUserControl.xaml
├── ContractAddressUserControl.xaml.cs
├── Converters
│ ├── NullableDecimalConverter.cs
│ ├── NullableUInt64Converter.cs
│ └── NullableValueConvertor.cs
├── Designers
│ └── ContractAddressModelDesigner.cs
└── Nethereum.UI.Desktop.Common.csproj
├── Nethereum.UI.Desktop.sln
├── Nethereum.UI.Desktop
├── App.xaml
├── App.xaml.cs
├── Assets
│ ├── logo.ico
│ └── logo192x192t.png
├── FodyWeavers.xml
├── Nethereum.UI.Desktop.csproj
├── Program.cs
├── Styles
│ ├── Icons.xaml
│ ├── SideBar.xaml
│ └── Styles.xaml
├── ViewLocator.cs
├── ViewModels
│ ├── MainWindowViewModel.cs
│ └── ViewModelBase.cs
├── Views
│ ├── AccountUserControl.xaml
│ ├── AccountUserControl.xaml.cs
│ ├── AccountsUserControl.xaml
│ ├── AccountsUserControl.xaml.cs
│ ├── Designers
│ │ ├── AccountViewModelDesigner.cs
│ │ ├── AccountsViewModelDesigner.cs
│ │ ├── HdWalletAccountLoaderViewModelDesigner.cs
│ │ ├── KeyStoreLoaderViewModelDesigner.cs
│ │ ├── PrivateKeyAccountLoaderViewModelDesigner.cs
│ │ ├── SendTransactionViewModelDesigner.cs
│ │ ├── TransactionsViewModelDesigner.cs
│ │ └── UrlSettingModelDesigner.cs
│ ├── HdWalletUserControl.xaml
│ ├── HdWalletUserControl.xaml.cs
│ ├── KeystoreAccountLoaderUserControl.xaml
│ ├── KeystoreAccountLoaderUserControl.xaml.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── PrivateKeyAccountLoaderUserControl.xaml
│ ├── PrivateKeyAccountLoaderUserControl.xaml.cs
│ ├── SendTransactionUserControl.xaml
│ ├── SendTransactionUserControl.xaml.cs
│ ├── TransactionsUserControl.xaml
│ ├── TransactionsUserControl.xaml.cs
│ ├── UrlSettingUserControl.xaml
│ └── UrlSettingUserControl.xaml.cs
└── nuget.config
├── Nethereum.UI.HostProvider
├── AppState
│ └── EthereumConnection.cs
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── Nethereum.UI.HostProvider.csproj
├── NethereumHostProvider.cs
├── Services
│ └── AccountsService.cs
└── ViewModels
│ ├── AccountItemViewModel.cs
│ ├── AccountViewModel.cs
│ ├── AccountsViewModel.cs
│ ├── AddAccount
│ ├── HdWalletAccountLoaderViewModel.cs
│ ├── HdWalletViewModel.cs
│ ├── KeyStoreLoaderViewModel.cs
│ └── PrivateKeyLoaderViewModel.cs
│ └── UrlSettingViewModel.cs
├── Nethereum.UI
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── IEthereumHostProvider.cs
├── Model
│ └── CurrentAccountTransaction.cs
├── Nethereum.UI.csproj
├── NethereumAuthenticator.cs
├── Services
│ ├── ContractService.cs
│ ├── CurrentAccountTransactionsService.cs
│ └── IContractService.cs
├── Util
│ └── Utils.cs
├── Validation
│ └── EthereumRules.cs
└── ViewModels
│ ├── Contracts
│ └── ContractAdddressViewModel.cs
│ └── Transactions
│ ├── SendTransactionViewModel.cs
│ ├── TransactionViewModel.cs
│ └── TransactionsViewModel.cs
├── README.md
└── Screenshots
└── simpleDemo.gif
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | #Backup
5 |
6 | Backup/
7 |
8 | # User-specific files
9 | *.suo
10 | *.user
11 | *.userosscache
12 | *.sln.docstates
13 |
14 | # User-specific files (MonoDevelop/Xamarin Studio)
15 | *.userprefs
16 |
17 | # Build results
18 | [Dd]ebug/
19 | [Dd]ebugPublic/
20 | [Rr]elease/
21 | [Rr]eleases/
22 | x64/
23 | x86/
24 | build/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | devChainRPCTests/
29 | testchain/clique/devChain/geth
30 | testchain/devChain/geth
31 | geth.exe
32 |
33 |
34 | # Visual Studio 2015 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # MSTest test Results
40 | [Tt]est[Rr]esult*/
41 | [Bb]uild[Ll]og.*
42 |
43 | # NUNIT
44 | *.VisualState.xml
45 | TestResult.xml
46 |
47 | # Build Results of an ATL Project
48 | [Dd]ebugPS/
49 | [Rr]eleasePS/
50 | dlldata.c
51 |
52 | # DNX
53 | project.lock.json
54 | artifacts/
55 |
56 | *_i.c
57 | *_p.c
58 | *_i.h
59 | *.ilk
60 | *.meta
61 | *.obj
62 | *.pch
63 | *.pdb
64 | *.pgc
65 | *.pgd
66 | *.rsp
67 | *.sbr
68 | *.tlb
69 | *.tli
70 | *.tlh
71 | *.tmp
72 | *.tmp_proj
73 | *.log
74 | *.vspscc
75 | *.vssscc
76 | .builds
77 | *.pidb
78 | *.svclog
79 | *.scc
80 |
81 | # Chutzpah Test files
82 | _Chutzpah*
83 |
84 | # Visual C++ cache files
85 | ipch/
86 | *.aps
87 | *.ncb
88 | *.opensdf
89 | *.sdf
90 | *.cachefile
91 |
92 | # Visual Studio profiler
93 | *.psess
94 | *.vsp
95 | *.vspx
96 | *.sap
97 |
98 | # TFS 2012 Local Workspace
99 | $tf/
100 |
101 | # Guidance Automation Toolkit
102 | *.gpState
103 |
104 | # ReSharper is a .NET coding add-in
105 | _ReSharper*/
106 | *.[Rr]e[Ss]harper
107 | *.DotSettings.user
108 |
109 | # JustCode is a .NET coding add-in
110 | .JustCode
111 |
112 | # TeamCity is a build add-in
113 | _TeamCity*
114 |
115 | # DotCover is a Code Coverage Tool
116 | *.dotCover
117 |
118 | # NCrunch
119 | _NCrunch_*
120 | .*crunch*.local.xml
121 | nCrunchTemp_*
122 |
123 | # MightyMoose
124 | *.mm.*
125 | AutoTest.Net/
126 |
127 | # Web workbench (sass)
128 | .sass-cache/
129 |
130 | # Installshield output folder
131 | [Ee]xpress/
132 |
133 | # DocProject is a documentation generator add-in
134 | DocProject/buildhelp/
135 | DocProject/Help/*.HxT
136 | DocProject/Help/*.HxC
137 | DocProject/Help/*.hhc
138 | DocProject/Help/*.hhk
139 | DocProject/Help/*.hhp
140 | DocProject/Help/Html2
141 | DocProject/Help/html
142 |
143 | # Click-Once directory
144 | publish/
145 |
146 | # Publish Web Output
147 | *.[Pp]ublish.xml
148 | *.azurePubxml
149 | # TODO: Comment the next line if you want to checkin your web deploy settings
150 | # but database connection strings (with potential passwords) will be unencrypted
151 | *.pubxml
152 | *.publishproj
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 |
163 | # Windows Azure Build Output
164 | csx/
165 | *.build.csdef
166 |
167 | # Windows Azure Emulator
168 | efc/
169 | rfc/
170 |
171 | # Windows Store app package directory
172 | AppPackages/
173 |
174 | # Visual Studio cache files
175 | # files ending in .cache can be ignored
176 | *.[Cc]ache
177 | # but keep track of directories ending in .cache
178 | !*.[Cc]ache/
179 |
180 | # Others
181 | ClientBin/
182 | [Ss]tyle[Cc]op.*
183 | ~$*
184 | *~
185 | *.dbmdl
186 | *.dbproj.schemaview
187 | *.pfx
188 | *.publishsettings
189 | node_modules/
190 | orleans.codegen.cs
191 |
192 | # RIA/Silverlight projects
193 | Generated_Code/
194 |
195 | # Backup & report files from converting an old project file
196 | # to a newer Visual Studio version. Backup files are not needed,
197 | # because we have git ;-)
198 | _UpgradeReport_Files/
199 | Backup*/
200 | UpgradeLog*.XML
201 | UpgradeLog*.htm
202 |
203 | # SQL Server files
204 | *.mdf
205 | *.ldf
206 |
207 | # Business Intelligence projects
208 | *.rdl.data
209 | *.bim.layout
210 | *.bim_*.settings
211 |
212 | # Microsoft Fakes
213 | FakesAssemblies/
214 |
215 | # GhostDoc plugin setting file
216 | *.GhostDoc.xml
217 |
218 | # Node.js Tools for Visual Studio
219 | .ntvs_analysis.dat
220 |
221 | # Visual Studio 6 build log
222 | *.plg
223 |
224 | # Visual Studio 6 workspace options file
225 | *.opt
226 |
227 | # Visual Studio LightSwitch build output
228 | **/*.HTMLClient/GeneratedArtifacts
229 | **/*.DesktopClient/GeneratedArtifacts
230 | **/*.DesktopClient/ModelManifest.xml
231 | **/*.Server/GeneratedArtifacts
232 | **/*.Server/ModelManifest.xml
233 | _Pvt_Extensions
234 |
235 | # Paket dependency manager
236 | .paket/paket.exe
237 |
238 | # FAKE - F# Make
239 | .fake/
240 |
241 | # Windows image file caches
242 | Thumbs.db
243 | ehthumbs.db
244 |
245 | # Folder config file
246 | Desktop.ini
247 |
248 | # Recycle Bin used on file shares
249 |
250 | $RECYCLE.BIN/
251 |
252 | # Windows Installer files
253 | *.cab
254 | *.msi
255 | *.msm
256 | *.msp
257 |
258 | # Windows shortcuts
259 | *.lnk
260 |
261 | # =========================
262 | # Operating System Files
263 | # =========================
264 |
265 | # OSX
266 | # =========================
267 |
268 | .DS_Store
269 | .AppleDouble
270 | .LSOverride
271 |
272 | # Thumbnails
273 | ._*
274 |
275 | # Files that might appear on external disk
276 | .Spotlight-V100
277 | .Trashes
278 |
279 | # Directories potentially created on remote AFP share
280 | .AppleDB
281 | .AppleDesktop
282 | Network Trash Folder
283 | Temporary Items
284 | .apdisk
285 |
286 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Nethereum.com (Juan Blanco) , Logo by Cass (https://github.com/cassiopaia)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or ANY portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.Desktop/Designers/StandardTokenBalanceOfViewModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.StandardToken.UI.ViewModels;
2 |
3 | namespace Nethereum.StandardToken.Desktop.Designers
4 | {
5 | public class StandardTokenBalanceOfViewModelDesigner : StandardTokenBalanceOfViewModel
6 | {
7 | public StandardTokenBalanceOfViewModelDesigner()
8 | {
9 | this.AccountAddress = "0xkfljas324908789fiofoisudfsfslkfjls";
10 | this.Balance = 100;
11 |
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/Nethereum.StandardToken.Desktop/Designers/StandardTokenTransferViewModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.StandardToken.UI.ViewModels;
2 | using Nethereum.UI.ViewModels;
3 |
4 | namespace Nethereum.StandardToken.Desktop.Designers
5 | {
6 | public class StandardTokenTransferViewModelDesigner : StandardTokenTransferViewModel
7 | {
8 | public StandardTokenTransferViewModelDesigner()
9 | {
10 | this.AddressTo = "0x13f022d72158410433cbd66f5dd8bf6d2d129924";
11 | this.Amount = 100;
12 |
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Nethereum.StandardToken.Desktop/Nethereum.StandardToken.Desktop.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.1
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.Desktop/StandardTokenBalanceOfUserControl.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.Desktop/StandardTokenBalanceOfUserControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace Nethereum.StandardToken.Desktop
5 | {
6 | public class StandardTokenBalanceOfUserControl : UserControl
7 | {
8 | public StandardTokenBalanceOfUserControl()
9 | {
10 | this.InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.Desktop/StandardTokenTransferUserControl.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
27 |
28 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.Desktop/StandardTokenTransferUserControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia.Controls;
3 | using Avalonia.Markup.Xaml;
4 | using Nethereum.StandardToken.UI.ViewModels;
5 | using ReactiveUI.Validation.Extensions;
6 | using ReactiveUI;
7 | using System.Reactive.Disposables;
8 |
9 | namespace Nethereum.StandardToken.Desktop
10 | {
11 | public class StandardTokenTransferUserControl : UserControl, IViewFor
12 | {
13 | private TextBlock ToValidation => this.FindControl("ToValidation");
14 | private TextBlock AmountValidation => this.FindControl("AmountValidation");
15 |
16 | public StandardTokenTransferUserControl()
17 | {
18 | this.InitializeComponent();
19 | }
20 |
21 | protected override void OnDataContextChanged(EventArgs e)
22 | {
23 | this.ViewModel = (StandardTokenTransferViewModel)DataContext;
24 |
25 | this.WhenActivated(disposables =>
26 | {
27 | this.BindValidation(ViewModel, x => x.AddressTo, x => x.ToValidation.Text)
28 | .DisposeWith(disposables);
29 |
30 | this.BindValidation(ViewModel, x => x.Amount, x => x.AmountValidation.Text)
31 | .DisposeWith(disposables);
32 | });
33 | }
34 |
35 | private void InitializeComponent()
36 | {
37 | AvaloniaXamlLoader.Load(this);
38 | }
39 |
40 | Window GetWindow() => (Window)this.VisualRoot;
41 |
42 | object IViewFor.ViewModel
43 | {
44 | get { return ViewModel; }
45 | set { ViewModel = (StandardTokenTransferViewModel) value; }
46 | }
47 |
48 | public StandardTokenTransferViewModel ViewModel { get; set; }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.Desktop/StandardTokenUserControl.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.Desktop/StandardTokenUserControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 | using Nethereum.UI.Desktop.ViewModels;
4 | using ReactiveUI;
5 | using System;
6 |
7 | namespace Nethereum.StandardToken.Desktop
8 | {
9 | public class StandardTokenUserControl : UserControl, IViewFor
10 | {
11 | public StandardTokenUserControl()
12 | {
13 | this.InitializeComponent();
14 | }
15 |
16 | private void InitializeComponent()
17 | {
18 | AvaloniaXamlLoader.Load(this);
19 | }
20 |
21 | protected override void OnDataContextChanged(EventArgs e)
22 | {
23 | this.ViewModel = (StandardTokenViewModel)DataContext;
24 | }
25 |
26 | Window GetWindow() => (Window)this.VisualRoot;
27 |
28 | object IViewFor.ViewModel
29 | {
30 | get { return ViewModel; }
31 | set { ViewModel = (StandardTokenViewModel)value; }
32 | }
33 |
34 | public StandardTokenViewModel ViewModel { get; set; }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.UI/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.UI/FodyWeavers.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
12 |
13 |
14 |
15 |
16 | A comma-separated list of error codes that can be safely ignored in assembly verification.
17 |
18 |
19 |
20 |
21 | 'false' to turn off automatic generation of the XML Schema file.
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.UI/Nethereum.StandardToken.UI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Nethereum.StandardToken.UI/SmartContractMessages/BalanceOfFunction.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.ABI.FunctionEncoding.Attributes;
2 | using Nethereum.Contracts;
3 |
4 | namespace Nethereum.StandardToken.UI.SmartContractMessages
5 | {
6 | [Function("balanceOf", "uint256")]
7 | public class BalanceOfFunction : FunctionMessage
8 | {
9 | [Parameter("address", "_owner", 1)]
10 | public string Owner { get; set; }
11 | }
12 | }
--------------------------------------------------------------------------------
/Nethereum.StandardToken.UI/SmartContractMessages/TransferFunction.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.ABI.FunctionEncoding.Attributes;
2 | using Nethereum.Contracts;
3 | using System.Numerics;
4 |
5 | namespace Nethereum.StandardToken.UI.SmartContractMessages
6 | {
7 | [Function("transfer", "bool")]
8 | public class TransferFunction : FunctionMessage
9 | {
10 | [Parameter("address", "_to", 1)]
11 | public string To { get; set; }
12 |
13 | [Parameter("uint256", "_value", 2)]
14 | public BigInteger TokenAmount { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/Nethereum.StandardToken.UI/ViewModels/StandardTokenBalanceOfViewModel.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Ensure;
2 | using Nethereum.StandardToken.UI.SmartContractMessages;
3 | using Nethereum.UI;
4 | using Nethereum.UI.Services;
5 | using ReactiveUI;
6 | using ReactiveUI.Fody.Helpers;
7 | using ReactiveUI.Validation.Helpers;
8 | using System;
9 | using System.Numerics;
10 | using System.Reactive;
11 | using System.Reactive.Linq;
12 | using System.Runtime.InteropServices.WindowsRuntime;
13 | using System.Threading.Tasks;
14 |
15 | namespace Nethereum.StandardToken.UI.ViewModels
16 | {
17 | public class StandardTokenBalanceOfViewModel : ReactiveValidationObject
18 | {
19 | [Reactive] public string ContractAddress { get; set; }
20 | [Reactive] public string AccountAddress { get; set; }
21 | [Reactive] public decimal Balance { get; set; }
22 |
23 | private readonly ReactiveCommand _refreshBalanceCommand;
24 | private readonly IEthereumHostProvider ethereumHostProvider;
25 | private readonly IContractService contractService;
26 |
27 | public ReactiveCommand RefreshBalanceCommand => this._refreshBalanceCommand;
28 |
29 | protected StandardTokenBalanceOfViewModel()
30 | {
31 |
32 | }
33 |
34 | public StandardTokenBalanceOfViewModel(IEthereumHostProvider ethereumHostProvider, IContractService contractService)
35 | {
36 | this.ethereumHostProvider = ethereumHostProvider;
37 | this.ethereumHostProvider.SelectedAccountCallback.Subscribe(address => AccountAddress = address);
38 |
39 | this.contractService = contractService;
40 | this.contractService.ContractAddress.Subscribe(x => ContractAddress = x);
41 |
42 | var hasValidAddresses = this.WhenAnyValue(x => x.AccountAddress, x => x.ContractAddress,
43 | (address, contractAddress) => Nethereum.UI.Util.Utils.IsValidAddress(address) && Nethereum.UI.Util.Utils.IsValidAddress(contractAddress));
44 |
45 | var isValidRefreshBalance = Observable.CombineLatest(hasValidAddresses, this.ethereumHostProvider.EnabledCallBack, (validAdress, enabled) => validAdress && enabled);
46 |
47 | isValidRefreshBalance.Where(x => x == true)
48 | .Subscribe(async _ => await RefreshBalanceAsync());
49 |
50 | _refreshBalanceCommand = ReactiveCommand.CreateFromTask(RefreshBalanceAsync, isValidRefreshBalance);
51 |
52 | }
53 |
54 |
55 | public async Task RefreshBalanceAsync()
56 | {
57 | Balance = await GetBalanceAsync();
58 | return true;
59 | }
60 |
61 | public async Task GetBalanceAsync()
62 | {
63 | Ensure.ArgumentNotNull(this.AccountAddress, "Address");
64 | Ensure.ArgumentNotNull(this.ContractAddress, "ContractAddress");
65 |
66 | var web3 = await ethereumHostProvider.GetWeb3Async();
67 | var handler = web3.Eth.GetContractHandler(ContractAddress);
68 | var balanceMessage = new BalanceOfFunction(){Owner = AccountAddress};
69 | var balance = await handler.QueryAsync(balanceMessage);
70 |
71 | //assuming all have 18 decimals
72 | var value = Web3.Web3.Convert.FromWeiToBigDecimal(balance);
73 | return decimal.Parse(value.ToString());
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/Nethereum.StandardToken.UI/ViewModels/StandardTokenTransferViewModel.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Ensure;
2 | using Nethereum.Contracts;
3 | using Nethereum.Hex.HexConvertors.Extensions;
4 | using Nethereum.StandardToken.UI.SmartContractMessages;
5 | using Nethereum.UI;
6 | using Nethereum.UI.Services;
7 | using Nethereum.UI.ViewModels;
8 | using ReactiveUI;
9 | using ReactiveUI.Fody.Helpers;
10 | using ReactiveUI.Validation.Extensions;
11 | using ReactiveUI.Validation.Helpers;
12 | using System;
13 | using System.Reactive;
14 | using System.Reactive.Linq;
15 | using System.Threading.Tasks;
16 |
17 | namespace Nethereum.StandardToken.UI.ViewModels
18 | {
19 | public class StandardTokenTransferViewModel : ReactiveValidationObject
20 | {
21 | [Reactive] public string ContractAddress { get; set; }
22 | [Reactive] public string AddressTo { get; set; }
23 | [Reactive] public decimal? Amount { get; set; }
24 |
25 | private readonly IEthereumHostProvider _ethereumHostProvider;
26 | private readonly IContractService _contractService;
27 | private readonly IScreen _screenHost;
28 |
29 | protected ReactiveCommand _executeTransactionCommand;
30 | public ReactiveCommand ExecuteTransactionCommand => this._executeTransactionCommand;
31 |
32 |
33 | protected StandardTokenTransferViewModel()
34 | {
35 |
36 | }
37 |
38 | public StandardTokenTransferViewModel(IEthereumHostProvider ethereumHostProvider, IContractService contractService, IScreen screenHost)
39 | {
40 | this._ethereumHostProvider = ethereumHostProvider;
41 | this._contractService = contractService;
42 | this._screenHost = screenHost;
43 | this._contractService.ContractAddress.Subscribe(x => ContractAddress = x);
44 |
45 | this.ValidationRule(x => x.AddressTo, address => Nethereum.UI.Util.Utils.IsValidAddress(address), "Address is not valid");
46 | this.ValidationRule(x => x.Amount, amount => amount >= 0, "Amount cannot be negative");
47 |
48 |
49 |
50 | var canExecuteTransaction = this.WhenAnyValue(
51 | x => x.AddressTo,
52 | x => x.Amount,
53 | x => x.ContractAddress,
54 | (addressTo, amount, contractAddress) =>
55 | Nethereum.UI.Util.Utils.IsValidAddress(addressTo) &&
56 | amount != null && amount > 0 &&
57 | contractAddress != null);
58 |
59 | var canExecuteAndEnabled = Observable.CombineLatest(canExecuteTransaction, _ethereumHostProvider.EnabledCallBack, (valid, enabled) => valid && enabled);
60 |
61 | this._executeTransactionCommand = ReactiveCommand.CreateFromTask(ExecuteAsync, canExecuteAndEnabled);
62 |
63 | }
64 |
65 | public async Task ExecuteAsync()
66 | {
67 | Ensure.ArgumentNotNullOrEmpty(this.AddressTo, "Address To");
68 | Ensure.ArgumentNotNull(this.Amount, "Token Amount");
69 |
70 | var transferfuction =
71 | new TransferFunction
72 | {
73 | TokenAmount = Web3.Web3.Convert.ToWei(Amount.Value),
74 | To = AddressTo
75 | };
76 |
77 | var transactionViewModel = new SendTransactionViewModel(_ethereumHostProvider, _screenHost);
78 | await transactionViewModel.InitialiseAsync(transferfuction, ContractAddress);
79 | await _screenHost.Router.Navigate.Execute(transactionViewModel);
80 |
81 | }
82 |
83 | }
84 | }
--------------------------------------------------------------------------------
/Nethereum.StandardToken.UI/ViewModels/StandardTokenViewModel.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.StandardToken.UI.ViewModels;
2 | using Nethereum.UI.Services;
3 | using Nethereum.UI.ViewModels.Contracts;
4 | using ReactiveUI;
5 | using ReactiveUI.Fody.Helpers;
6 | using Splat;
7 |
8 | namespace Nethereum.UI.Desktop.ViewModels
9 | {
10 | public class StandardTokenViewModel : ReactiveObject, IScreen
11 | {
12 | private readonly RoutingState routingState;
13 |
14 | [Reactive] public StandardTokenTransferViewModel StandardTokenTransferViewModel { get; set; }
15 | [Reactive] public ContractAdddressViewModel ContractAdddressViewModel { get; set; }
16 | [Reactive] public StandardTokenBalanceOfViewModel StandardTokenBalanceOfViewModel { get; set; }
17 |
18 | public StandardTokenViewModel(IEthereumHostProvider ethereumHostProvider)
19 | {
20 | this.routingState = new RoutingState();
21 |
22 | var provider = ethereumHostProvider ?? Locator.Current.GetService();
23 | var contractService =Locator.Current.GetService();
24 |
25 | ContractAdddressViewModel = new ContractAdddressViewModel(contractService);
26 | StandardTokenBalanceOfViewModel = new StandardTokenBalanceOfViewModel(provider, contractService);
27 | StandardTokenTransferViewModel = new StandardTokenTransferViewModel(provider, contractService, this);
28 | }
29 |
30 | public RoutingState Router => this.routingState;
31 | }
32 | }
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop.Common/ContractAddressUserControl.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | Address is not valid
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop.Common/ContractAddressUserControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 | using Nethereum.UI.ViewModels.Contracts;
4 | using ReactiveUI;
5 | using ReactiveUI.Validation.Extensions;
6 | using System;
7 | using System.Reactive.Disposables;
8 |
9 | namespace Nethereum.UI.Desktop.Common
10 | {
11 | public class ContractAddressUserControl : UserControl, IViewFor
12 | {
13 | public ContractAddressUserControl()
14 | {
15 | this.InitializeComponent();
16 | }
17 |
18 | private void InitializeComponent()
19 | {
20 | AvaloniaXamlLoader.Load(this);
21 | }
22 |
23 | protected override void OnDataContextChanged(EventArgs e)
24 | {
25 |
26 | this.ViewModel = (ContractAdddressViewModel)DataContext;
27 | }
28 |
29 | object IViewFor.ViewModel
30 | {
31 | get { return ViewModel; }
32 | set { ViewModel = (ContractAdddressViewModel)value; }
33 | }
34 |
35 | public ContractAdddressViewModel ViewModel { get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop.Common/Converters/NullableDecimalConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia.Data.Converters;
3 |
4 | namespace Nethereum.UI.Desktop.Common.Converters
5 | {
6 | public class NullableDecimalConverter : IValueConverter
7 | {
8 | private static readonly NullableDecimalConverter defaultInstance = new NullableDecimalConverter();
9 |
10 | public static NullableDecimalConverter Default { get { return defaultInstance; } }
11 |
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | if (value is decimal?)
15 | {
16 | decimal? decimalValue = (decimal?)value;
17 | if (decimalValue.HasValue)
18 | {
19 | return decimalValue.Value.ToString();
20 | }
21 | }
22 |
23 | return null;
24 | }
25 |
26 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
27 | {
28 | if (value is string)
29 | {
30 | decimal number;
31 | if (decimal.TryParse((string)value, out number))
32 | {
33 | return number;
34 | }
35 | }
36 |
37 | return null;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop.Common/Converters/NullableUInt64Converter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia.Data.Converters;
3 |
4 | namespace Nethereum.UI.Desktop.Common.Converters
5 | {
6 | public class NullableUInt64Converter : IValueConverter
7 | {
8 | private static readonly NullableUInt64Converter defaultInstance = new NullableUInt64Converter();
9 |
10 | public static NullableUInt64Converter Default { get { return defaultInstance; } }
11 |
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | if (value is ulong?)
15 | {
16 | ulong? typedValue = (ulong?)value;
17 | if (typedValue.HasValue)
18 | {
19 | return typedValue.Value.ToString();
20 | }
21 | }
22 |
23 | return null;
24 | }
25 |
26 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
27 | {
28 | if (value is string)
29 | {
30 | ulong number;
31 | if (ulong.TryParse((string)value, out number))
32 | {
33 | return number;
34 | }
35 | }
36 |
37 | return null;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop.Common/Converters/NullableValueConvertor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia.Data.Converters;
3 | using Avalonia.Markup;
4 |
5 | namespace Nethereum.UI.Desktop.Common.Converters
6 | {
7 | public class NullableIntConverter : IValueConverter
8 | {
9 | private static readonly NullableIntConverter defaultInstance = new NullableIntConverter();
10 |
11 | public static NullableIntConverter Default { get { return defaultInstance; } }
12 |
13 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
14 | {
15 | if (value is int?)
16 | {
17 | int? intValue = (int?)value;
18 | if (intValue.HasValue)
19 | {
20 | return intValue.Value.ToString();
21 | }
22 | }
23 |
24 | return null;
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
28 | {
29 | if (value is string)
30 | {
31 | int number;
32 | if (int.TryParse((string)value, out number))
33 | {
34 | return number;
35 | }
36 | }
37 |
38 | return null;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop.Common/Designers/ContractAddressModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.UI.ViewModels.Contracts;
2 |
3 | namespace Nethereum.UI.Desktop.Common.Designers
4 | {
5 | public class ContractAddressModelDesigner : ContractAdddressViewModel
6 | {
7 | public ContractAddressModelDesigner()
8 | {
9 | this.ContractAddress = "0x13f022d72158410433cbd66f5dd8bf6d2d129924";
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop.Common/Nethereum.UI.Desktop.Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | MSBuild:Compile
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30709.64
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.UI", "Nethereum.UI\Nethereum.UI.csproj", "{B9DBE599-1AA8-4041-A047-67EEC05E7735}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.UI.Desktop", "Nethereum.UI.Desktop\Nethereum.UI.Desktop.csproj", "{F98A5CEE-AD7E-4D5C-8219-3CE2155CEE53}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.StandardToken.UI", "Nethereum.StandardToken.UI\Nethereum.StandardToken.UI.csproj", "{E1ECFE47-6E5F-4908-A2DE-0E473F77D326}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.UI.HostProvider", "Nethereum.UI.HostProvider\Nethereum.UI.HostProvider.csproj", "{5BA2B3CA-FDFD-4980-9D90-A86EF6A8278C}"
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.UI.Desktop.Common", "Nethereum.UI.Desktop.Common\Nethereum.UI.Desktop.Common.csproj", "{A39CB3B3-AA6C-429B-AB7A-319EED7FC855}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.StandardToken.Desktop", "Nethereum.StandardToken.Desktop\Nethereum.StandardToken.Desktop.csproj", "{B14A8706-A7B2-4D73-BCF4-EF094B77AA3B}"
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|Any CPU = Debug|Any CPU
21 | Release|Any CPU = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {B9DBE599-1AA8-4041-A047-67EEC05E7735}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {B9DBE599-1AA8-4041-A047-67EEC05E7735}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {B9DBE599-1AA8-4041-A047-67EEC05E7735}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {B9DBE599-1AA8-4041-A047-67EEC05E7735}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {F98A5CEE-AD7E-4D5C-8219-3CE2155CEE53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {F98A5CEE-AD7E-4D5C-8219-3CE2155CEE53}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {F98A5CEE-AD7E-4D5C-8219-3CE2155CEE53}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {F98A5CEE-AD7E-4D5C-8219-3CE2155CEE53}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {E1ECFE47-6E5F-4908-A2DE-0E473F77D326}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {E1ECFE47-6E5F-4908-A2DE-0E473F77D326}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {E1ECFE47-6E5F-4908-A2DE-0E473F77D326}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {E1ECFE47-6E5F-4908-A2DE-0E473F77D326}.Release|Any CPU.Build.0 = Release|Any CPU
36 | {5BA2B3CA-FDFD-4980-9D90-A86EF6A8278C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {5BA2B3CA-FDFD-4980-9D90-A86EF6A8278C}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {5BA2B3CA-FDFD-4980-9D90-A86EF6A8278C}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {5BA2B3CA-FDFD-4980-9D90-A86EF6A8278C}.Release|Any CPU.Build.0 = Release|Any CPU
40 | {A39CB3B3-AA6C-429B-AB7A-319EED7FC855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41 | {A39CB3B3-AA6C-429B-AB7A-319EED7FC855}.Debug|Any CPU.Build.0 = Debug|Any CPU
42 | {A39CB3B3-AA6C-429B-AB7A-319EED7FC855}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {A39CB3B3-AA6C-429B-AB7A-319EED7FC855}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {B14A8706-A7B2-4D73-BCF4-EF094B77AA3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45 | {B14A8706-A7B2-4D73-BCF4-EF094B77AA3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
46 | {B14A8706-A7B2-4D73-BCF4-EF094B77AA3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {B14A8706-A7B2-4D73-BCF4-EF094B77AA3B}.Release|Any CPU.Build.0 = Release|Any CPU
48 | EndGlobalSection
49 | GlobalSection(SolutionProperties) = preSolution
50 | HideSolutionNode = FALSE
51 | EndGlobalSection
52 | GlobalSection(ExtensibilityGlobals) = postSolution
53 | SolutionGuid = {B41D979A-7ADB-4C07-B27D-2DEFCF24BC23}
54 | EndGlobalSection
55 | EndGlobal
56 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
28 |
32 |
37 |
38 |
44 |
45 |
50 |
51 |
52 |
62 |
65 |
68 |
69 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls.ApplicationLifetimes;
3 | using Avalonia.Markup.Xaml;
4 | using Nethereum.UI.Desktop.ViewModels;
5 | using Nethereum.UI.Desktop.Views;
6 |
7 | namespace Nethereum.UI.Desktop
8 | {
9 | public class App : Application
10 | {
11 | public override void Initialize()
12 | {
13 | AvaloniaXamlLoader.Load(this);
14 | }
15 |
16 | public override void OnFrameworkInitializationCompleted()
17 | {
18 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
19 | {
20 | desktop.MainWindow = new MainWindow
21 | {
22 | DataContext = new MainWindowViewModel(),
23 | };
24 | }
25 |
26 | base.OnFrameworkInitializationCompleted();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Assets/logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nethereum/Nethereum.UI.Desktop/792eaee6a553a261031d917c7729b396f4b33b7a/Nethereum.UI.Desktop/Assets/logo.ico
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Assets/logo192x192t.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nethereum/Nethereum.UI.Desktop/792eaee6a553a261031d917c7729b396f4b33b7a/Nethereum.UI.Desktop/Assets/logo192x192t.png
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Nethereum.UI.Desktop.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | WinExe
4 | netcoreapp3.1
5 | AnyCPU;x64;x86
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | MSBuild:Compile
37 |
38 |
39 | MSBuild:Compile
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Program.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.ReactiveUI;
3 | using Nethereum.UI.Desktop.Views;
4 | using Nethereum.UI.HostProvider;
5 | using Nethereum.UI.HostProvider.Services;
6 | using Nethereum.UI.Services;
7 | using Nethereum.UI.ViewModels;
8 | using ReactiveUI;
9 | using Splat;
10 |
11 | namespace Nethereum.UI.Desktop
12 | {
13 | class Program
14 | {
15 | public static void Main(string[] args) => BuildAvaloniaApp()
16 | .StartWithClassicDesktopLifetime(args);
17 |
18 | // Avalonia configuration, don't remove; also used by visual designer.
19 | public static AppBuilder BuildAvaloniaApp()
20 | {
21 | var nethereumHostProvider = new NethereumHostProvider();
22 | var currentAccountTransactionsService = new CurrentAccountTransactionsService(nethereumHostProvider);
23 | var accountsService = new AccountsService(nethereumHostProvider);
24 |
25 | Locator.CurrentMutable.RegisterConstant(accountsService);
26 | Locator.CurrentMutable.RegisterConstant(nethereumHostProvider);
27 | Locator.CurrentMutable.RegisterConstant(nethereumHostProvider, typeof(IEthereumHostProvider));
28 | Locator.CurrentMutable.RegisterConstant(new ContractService(), typeof(IContractService));
29 | Locator.CurrentMutable.RegisterConstant(currentAccountTransactionsService);
30 | Locator.CurrentMutable.Register(() => new SendTransactionUserControl(), typeof(IViewFor));
31 |
32 | return AppBuilder.Configure()
33 | .UsePlatformDetect()
34 | .LogToTrace()
35 | .UseReactiveUI();
36 |
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Styles/Icons.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Styles/SideBar.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
53 |
54 |
64 |
67 |
70 |
71 |
74 |
75 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Styles/Styles.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | 40 0 40 0
15 | avares://XamlControlsGallery/Assets/Fonts#Source Code Pro
16 |
17 |
18 |
21 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/ViewLocator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia.Controls;
3 | using Avalonia.Controls.Templates;
4 | using Nethereum.UI.Desktop.ViewModels;
5 |
6 | namespace Nethereum.UI.Desktop
7 | {
8 | public class ViewLocator : IDataTemplate
9 | {
10 | public bool SupportsRecycling => false;
11 |
12 | public IControl Build(object data)
13 | {
14 | var name = data.GetType().FullName.Replace("ViewModel", "View");
15 | var type = Type.GetType(name);
16 |
17 | if (type != null)
18 | {
19 | return (Control)Activator.CreateInstance(type);
20 | }
21 | else
22 | {
23 | return new TextBlock { Text = "Not Found: " + name };
24 | }
25 | }
26 |
27 | public bool Match(object data)
28 | {
29 | return data is ViewModelBase;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/ViewModels/MainWindowViewModel.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.UI.HostProvider;
2 | using Nethereum.UI.HostProvider.Services;
3 | using Nethereum.UI.ViewModels;
4 | using ReactiveUI;
5 | using ReactiveUI.Fody.Helpers;
6 | using Splat;
7 |
8 | namespace Nethereum.UI.Desktop.ViewModels
9 | {
10 | public class MainWindowViewModel : ReactiveObject
11 | {
12 | [Reactive] public PrivateKeyLoaderViewModel PrivateKeyLoaderViewModel { get; set; }
13 | [Reactive] public AccountViewModel AccountViewModel { get; set; }
14 |
15 | [Reactive] public AccountsViewModel AccountsViewModel { get; set; }
16 | [Reactive] public UrlSettingViewModel UrlSettingViewModel { get; set; }
17 |
18 | [Reactive] public KeyStoreLoaderViewModel KeyStoreLoaderViewModel { get; set; }
19 |
20 | [Reactive] public SendTransactionViewModel SendTransactionViewModel { get; set; }
21 |
22 | [Reactive] public TransactionsViewModel TransactionsViewModel { get; set; }
23 |
24 | [Reactive] public StandardTokenViewModel StandardTokenViewModel { get; set; }
25 |
26 | [Reactive] public HdWalletAccountLoaderViewModel HdWalletAccountLoaderViewModel { get; set; }
27 |
28 |
29 | public MainWindowViewModel()
30 | {
31 | var nethereumHostProvider = Locator.Current.GetService();
32 | var accountService = Locator.Current.GetService();
33 | var currentAccountsTransactionsService = Locator.Current.GetService();
34 |
35 | //Add an account to the account service so we have one already
36 | accountService.AddAccount(new Web3.Accounts.Account("0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7"));
37 |
38 | PrivateKeyLoaderViewModel = new PrivateKeyLoaderViewModel(accountService);
39 | PrivateKeyLoaderViewModel.PrivateKey = "0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7";
40 | //Default the private key
41 |
42 | AccountViewModel = new AccountViewModel(nethereumHostProvider);
43 | AccountsViewModel = new AccountsViewModel(nethereumHostProvider, accountService);
44 | KeyStoreLoaderViewModel = new KeyStoreLoaderViewModel(accountService);
45 | SendTransactionViewModel = new SendTransactionViewModel(nethereumHostProvider);
46 | TransactionsViewModel =new TransactionsViewModel(nethereumHostProvider, currentAccountsTransactionsService);
47 | StandardTokenViewModel = new StandardTokenViewModel(nethereumHostProvider);
48 | UrlSettingViewModel = new UrlSettingViewModel(nethereumHostProvider);
49 | UrlSettingViewModel.Url = "http://localhost:8545";
50 | //Default simple url
51 |
52 | //Default someone to send something
53 | SendTransactionViewModel.AddressTo = "0x243e72b69141f6af525a9a5fd939668ee9f2b354";
54 |
55 | HdWalletAccountLoaderViewModel = new HdWalletAccountLoaderViewModel(accountService);
56 | //Default some words
57 | HdWalletAccountLoaderViewModel.Words = "ripple scissors kick mammal hire column oak again sun offer wealth tomorrow wagon turn fatal";
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/ViewModels/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 |
3 | namespace Nethereum.UI.Desktop.ViewModels
4 | {
5 | public class ViewModelBase : ReactiveObject
6 | {
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/AccountUserControl.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/AccountUserControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace Nethereum.UI.Desktop.Views
5 | {
6 | public class AccountUserControl : UserControl
7 | {
8 | public AccountUserControl()
9 | {
10 | this.InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/AccountsUserControl.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
17 |
20 |
22 |
23 |
24 |
27 |
28 |
29 |
30 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/AccountsUserControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace Nethereum.UI.Desktop.Views
5 | {
6 | public class AccountsUserControl : UserControl
7 | {
8 | public AccountsUserControl()
9 | {
10 | this.InitializeComponent();
11 | }
12 |
13 |
14 | private void InitializeComponent()
15 | {
16 | AvaloniaXamlLoader.Load(this);
17 | }
18 |
19 |
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/Designers/AccountViewModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.UI.ViewModels;
2 |
3 | namespace Nethereum.UI.Desktop.Views
4 | {
5 | public class AccountViewModelDesigner : AccountViewModel
6 | {
7 | public AccountViewModelDesigner()
8 | {
9 | this.Address = "0xkfljas324908789fiofoisudfsfslkfjls";
10 | this.Balance = 100;
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/Designers/AccountsViewModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using DynamicData;
2 | using Nethereum.UI.ViewModels;
3 |
4 | namespace Nethereum.UI.Desktop.Views
5 | {
6 | public class AccountsViewModelDesigner : AccountsViewModel
7 | {
8 | public AccountsViewModelDesigner()
9 | {
10 | Accounts.Add(new[] { new AccountItemViewModel()
11 | {
12 | Address = "0x13f022d72158410433cbd66f5dd8bf6d2d129924",
13 | Balance = 100
14 | },
15 | new AccountItemViewModel()
16 | {
17 | Address = "0x13f022d72158410433cbd66f5dd8bf6d2d129924",
18 | Balance = 10000
19 | } }); ;
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/Designers/HdWalletAccountLoaderViewModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.UI.ViewModels;
2 |
3 | namespace Nethereum.UI.Desktop.Views
4 | {
5 | public class HdWalletAccountLoaderViewModelDesigner : HdWalletAccountLoaderViewModel
6 | {
7 | public HdWalletAccountLoaderViewModelDesigner()
8 | {
9 | this.Words = "ripple scissors kick mammal hire column oak again sun offer wealth tomorrow wagon turn fatal";
10 | this.SeedPassword = "Password";
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/Designers/KeyStoreLoaderViewModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.UI.ViewModels;
2 |
3 | namespace Nethereum.UI.Desktop.Views
4 | {
5 | public class KeyStoreLoaderViewModelDesigner : KeyStoreLoaderViewModel
6 | {
7 | public KeyStoreLoaderViewModelDesigner()
8 | {
9 | this.FileName = "C:/test/test";
10 | this.Password = "Password";
11 |
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/Designers/PrivateKeyAccountLoaderViewModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.UI.ViewModels;
2 |
3 | namespace Nethereum.UI.Desktop.Views
4 | {
5 | public class PrivateKeyAccountLoaderViewModelDesigner: PrivateKeyLoaderViewModel
6 | {
7 | public PrivateKeyAccountLoaderViewModelDesigner()
8 | {
9 | this.PrivateKey = "0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7";
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/Designers/SendTransactionViewModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.UI.ViewModels;
2 |
3 | namespace Nethereum.UI.Desktop.Views.Designers
4 | {
5 | public class SendTransactionViewModelDesigner : SendTransactionViewModel
6 | {
7 | public SendTransactionViewModelDesigner()
8 | {
9 | this.AddressTo = "0x13f022d72158410433cbd66f5dd8bf6d2d129924";
10 | this.AmountInEther = 100;
11 | this.Gas = (ulong)Nethereum.Signer.Transaction.DEFAULT_GAS_LIMIT;
12 | this.GasPrice = (ulong)Nethereum.Signer.Transaction.DEFAULT_GAS_PRICE;
13 | this.Nonce = 1;
14 |
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/Designers/TransactionsViewModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using DynamicData;
2 | using Nethereum.UI.ViewModels;
3 |
4 | namespace Nethereum.UI.Desktop.Views
5 | {
6 | public class TransactionsViewModelDesigner : TransactionsViewModel
7 | {
8 | public TransactionsViewModelDesigner()
9 | {
10 | Transactions.Add(new[] { new TransactionViewModel()
11 | {
12 | Amount = 10,
13 | BlockHash = "0x13f022d72158410433cbd66f5dd8bf6d2d129924",
14 | TransactionHash = "0x13f022d72158410433cbd66f5dd8bf6d2d129924",
15 | To= "0x13f022d72158410433cbd66f5dd8bf6d2d129924",
16 | From = "0x13f022d72158410433cbd66f5dd8bf6d2d129924",
17 | Gas = 12345,
18 | Nonce = 2,
19 | Status = TransactionViewModel.STATUS_INPROGRESS
20 |
21 | },
22 |
23 | new TransactionViewModel()
24 | {
25 | Amount = 15,
26 | BlockHash = "0x13f022d72158410433cbd66f5dd8bf6d2d129924",
27 | TransactionHash = "0x13f022d72158410433cbd66f5dd8bf6d2d129924",
28 | To = "0x13f022d72158410433cbd66f5dd8bf6d2d129924",
29 | From = "0x13f022d72158410433cbd66f5dd8bf6d2d129924",
30 | Gas = 345678,
31 | Nonce = 1,
32 | Status = TransactionViewModel.STATUS_COMPLETED
33 |
34 | }});
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/Designers/UrlSettingModelDesigner.cs:
--------------------------------------------------------------------------------
1 | using Nethereum.UI.ViewModels;
2 |
3 | namespace Nethereum.UI.Desktop.Views
4 | {
5 | public class UrlSettingModelDesigner : UrlSettingViewModel
6 | {
7 | public UrlSettingModelDesigner()
8 | {
9 | this.Url = "http://localhost:8545";
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/HdWalletUserControl.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
25 |
28 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/HdWalletUserControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 | using Nethereum.UI.ViewModels;
4 |
5 | namespace Nethereum.UI.Desktop.Views
6 | {
7 | public class HdWalletUserControl : UserControl
8 | {
9 | public HdWalletUserControl()
10 | {
11 | this.InitializeComponent();
12 | }
13 |
14 | private void InitializeComponent()
15 | {
16 | AvaloniaXamlLoader.Load(this);
17 | }
18 |
19 | Window GetWindow() => (Window)this.VisualRoot;
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/KeystoreAccountLoaderUserControl.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
16 |
17 |
18 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Nethereum.UI.Desktop/Views/KeystoreAccountLoaderUserControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 | using Nethereum.UI.ViewModels;
4 |
5 | namespace Nethereum.UI.Desktop.Views
6 | {
7 | public class KeystoreAccountLoaderUserControl : UserControl
8 | {
9 | public KeystoreAccountLoaderUserControl()
10 | {
11 | this.InitializeComponent();
12 | }
13 |
14 | private void InitializeComponent()
15 | {
16 | AvaloniaXamlLoader.Load(this);
17 |
18 | this.FindControl