From 5a1d17be1eb1b20e955c87adadb2d8603ba02b9f Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 10 Apr 2021 20:33:39 +0300 Subject: [PATCH 1/2] Fix Tezos/Ethereum receive view addresses doubling in cases while token addresses not null. Now they are distinct; --- .DS_Store | Bin 0 -> 8196 bytes Atomex.Client.Wpf.Tests/.DS_Store | Bin 0 -> 6148 bytes Atomex.Client.Wpf/.DS_Store | Bin 0 -> 8196 bytes Atomex.Client.Wpf/Atomex.Client.Wpf.csproj | 1 + .../Common/DistinctExtensions.cs | 21 ++++++++++++++++++ .../EthereumReceiveViewModel.cs | 4 +++- .../TezosReceiveViewModel.cs | 4 +++- 7 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .DS_Store create mode 100644 Atomex.Client.Wpf.Tests/.DS_Store create mode 100644 Atomex.Client.Wpf/.DS_Store create mode 100644 Atomex.Client.Wpf/Common/DistinctExtensions.cs diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0bba4c83205431a16efafb54c12a4629fd22a17d GIT binary patch literal 8196 zcmeHMzl#$=6n>)-10tMSczDfTA;J|xN*mdWD~AXooM0uGO=1$=xFJ8lM%YHMv^oxi zs}2MU!R87pQH1*s#H$231q(YxJHIzGcbRdMxSJ~sI0HN1X6C(_?|nO&$=eW-C=Y5S zqIn`J;$oaThH6CNe!f!WkZxH73iwmhD6LlGb|+=&8k_=70jGddz$xGqm=y(ZW^*Zy zIrmkstDOQ)f&Wqg-XA<%jK0Q1q1-x9$rJ!sK(j2kpW_>#r_tA#C`1p6P_97bDs+k= zlsnozZRcxD6e@QTI{6TKW}!0_A!o<%wDPBzx>UEBv5b_-&*Z$akzCz=AvtIC9Y&Ma*NRipr4tk5 zyh$CpQ|ncuFpeYM?K7BLqLjO9*}P0iTCblz-cgS+!+hov%japyam`~v7XB^=9{&|A zgB}(_1&boWqUc&Niwm36k7Vl5-+eTA{#h=KDS4UN9DFoOFL9mqI-NRCF` zt7iTYOnp9``t@>Kt&^NQOkJiQ#nwaq*eT)*Q=ux|L*3x0&4|zZ*u98|Q#NKy$HSj{ zF^#Yre)T8WnY5uE4z|MK|v|Fa&3LI^rW(`a~Rp6>t>x2$sCDM@^!n zu&WT7k;X5Xk0*XnGBy#J>3uOF8WT|hWgP5b=n?j_c4Q!yL!jX~CbJ7yR-HIC{9Ok4 z-3=+H1+A8so%bi6(q&n`bU9*^&yRh1Zs&MRHv>E{`*cP(-j@WuVQ#Fy4;2 z|Ks$v>HObL(mQ298TeNWm{B&%rdX2n*3RO%*IMW~l!fDb#B~ZTLMuirx8fsc5ZEnW V08>F95f+GU1Og2@C<9w%;2T=AXZ-*G literal 0 HcmV?d00001 diff --git a/Atomex.Client.Wpf/.DS_Store b/Atomex.Client.Wpf/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..46fcd2e0b46f948dddc76ae37fa0928aa30e1df3 GIT binary patch literal 8196 zcmeI1J!lj`6vyA@zGGuy5u323pn_2l8)1{2As_+uB$YzEI z@XQulIpevnvi4{lunufV2gLl~Vi(cVv8|$`8x-PF-b3`aFb-W760Psg^3syR8TIXSwrqgN=7td4fBl#}DBXphzb>p;>0v39Re zA2n!#&hYhnPi-`4wp4?mO1i2URI7DAs3Timyts7w=lkW}EaliHm8}V0xsC29M|Hec znDWPYMkLlUoa4#0Uxn5S$)VddgQ#{gYu1y!7O5X^F`D=b;#KG8p)m5i_U#{`2Qf`V zkfkv=)GSt(98)xdH!1=7;;jmEz!|;+mV}1$3_Myq`ux81B1IQ5t*0}%)TG;~x#lox zra>o;CL8S^1Y4?(^ZkAo@?~fv#*MTFCoQ2om1q!bKDE*akDp2^INR&*AzQ2;KAy5w zCXc+4@?Z&QJnmJ=2T7RY3@<-lUAulPA9<3NH|xr$VGdR6bk-O>#aG>^sx!Riv(=gW z$|rsQ$aehuCbLGp(mr&G>wZj*SmpZ+?%hWGJKx%orQG0!_iM8iWz4;cBFojXSyd>&xcFQSYmstNF$$tO8+3u{)I$$064;^sw)mpU=;CgMH z_zL1@pNoA2yV!)Tt)gs#gZyQPD3{}i;Xe%V*@aZJ@pNpfh%?y!&Wiy1{I}2l + diff --git a/Atomex.Client.Wpf/Common/DistinctExtensions.cs b/Atomex.Client.Wpf/Common/DistinctExtensions.cs new file mode 100644 index 0000000..1cfaf21 --- /dev/null +++ b/Atomex.Client.Wpf/Common/DistinctExtensions.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace Atomex.Client.Wpf.Common +{ + public static class DistinctExtensions + { + public static IEnumerable DistinctBy + (this IEnumerable source, Func keySelector) + { + HashSet seenKeys = new HashSet(); + foreach (TSource element in source) + { + if (seenKeys.Add(keySelector(element))) + { + yield return element; + } + } + } + } +} \ No newline at end of file diff --git a/Atomex.Client.Wpf/ViewModels/ReceiveViewModels/EthereumReceiveViewModel.cs b/Atomex.Client.Wpf/ViewModels/ReceiveViewModels/EthereumReceiveViewModel.cs index a17c9e6..2611132 100644 --- a/Atomex.Client.Wpf/ViewModels/ReceiveViewModels/EthereumReceiveViewModel.cs +++ b/Atomex.Client.Wpf/ViewModels/ReceiveViewModels/EthereumReceiveViewModel.cs @@ -38,7 +38,9 @@ public override Currency Currency .GetFreeExternalAddressAsync(_currency.Name) .WaitForResult(); - var receiveAddresses = activeTokenAddresses.Select(w => new WalletAddressViewModel(w, _currency.Format)) + var receiveAddresses = activeTokenAddresses + .DistinctBy(wa => wa.Address) + .Select(w => new WalletAddressViewModel(w, _currency.Format)) .Concat(activeAddresses.Select(w => new WalletAddressViewModel(w, _currency.Format))) .ToList(); diff --git a/Atomex.Client.Wpf/ViewModels/ReceiveViewModels/TezosReceiveViewModel.cs b/Atomex.Client.Wpf/ViewModels/ReceiveViewModels/TezosReceiveViewModel.cs index 2037378..a7d79e0 100644 --- a/Atomex.Client.Wpf/ViewModels/ReceiveViewModels/TezosReceiveViewModel.cs +++ b/Atomex.Client.Wpf/ViewModels/ReceiveViewModels/TezosReceiveViewModel.cs @@ -38,7 +38,9 @@ public override Currency Currency .GetFreeExternalAddressAsync(_currency.Name) .WaitForResult(); - var receiveAddresses = activeTokenAddresses.Select(w => new WalletAddressViewModel(w, _currency.Format)) + var receiveAddresses = activeTokenAddresses + .DistinctBy(wa => wa.Address) + .Select(w => new WalletAddressViewModel(w, _currency.Format)) .Concat(activeAddresses.Select(w => new WalletAddressViewModel(w, _currency.Format))) .ToList(); From f742594434c65c2fee19299bd1170c67167445ff Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 10 Apr 2021 20:36:45 +0300 Subject: [PATCH 2/2] .DS_Store banished! --- .DS_Store | Bin 8196 -> 0 bytes .gitignore | 2 +- Atomex.Client.Wpf.Tests/.DS_Store | Bin 6148 -> 0 bytes Atomex.Client.Wpf/.DS_Store | Bin 8196 -> 0 bytes 4 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 .DS_Store delete mode 100644 Atomex.Client.Wpf.Tests/.DS_Store delete mode 100644 Atomex.Client.Wpf/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 0bba4c83205431a16efafb54c12a4629fd22a17d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMzl#$=6n>)-10tMSczDfTA;J|xN*mdWD~AXooM0uGO=1$=xFJ8lM%YHMv^oxi zs}2MU!R87pQH1*s#H$231q(YxJHIzGcbRdMxSJ~sI0HN1X6C(_?|nO&$=eW-C=Y5S zqIn`J;$oaThH6CNe!f!WkZxH73iwmhD6LlGb|+=&8k_=70jGddz$xGqm=y(ZW^*Zy zIrmkstDOQ)f&Wqg-XA<%jK0Q1q1-x9$rJ!sK(j2kpW_>#r_tA#C`1p6P_97bDs+k= zlsnozZRcxD6e@QTI{6TKW}!0_A!o<%wDPBzx>UEBv5b_-&*Z$akzCz=AvtIC9Y&Ma*NRipr4tk5 zyh$CpQ|ncuFpeYM?K7BLqLjO9*}P0iTCblz-cgS+!+hov%japyam`~v7XB^=9{&|A zgB}(_1&boWqUc&Niwm36k7Vl5-+eTA{#h=KDS4UN9DFoOFL9mqI-NRCF` zt7iTYOnp9``t@>Kt&^NQOkJiQ#nwaq*eT)*Q=ux|L*3x0&4|zZ*u98|Q#NKy$HSj{ zF^#Yre)T8WnY5uE4z|MK|v|Fa&3LI^rW(`a~Rp6>t>x2$sCDM@^!n zu&WT7k;X5Xk0*XnGBy#J>3uOF8WT|hWgP5b=n?j_c4Q!yL!jX~CbJ7yR-HIC{9Ok4 z-3=+H1+A8so%bi6(q&n`bU9*^&yRh1Zs&MRHv>E{`*cP(-j@WuVQ#Fy4;2 z|Ks$v>HObL(mQ298TeNWm{B&%rdX2n*3RO%*IMW~l!fDb#B~ZTLMuirx8fsc5ZEnW V08>F95f+GU1Og2@C<9w%;2T=AXZ-*G diff --git a/Atomex.Client.Wpf/.DS_Store b/Atomex.Client.Wpf/.DS_Store deleted file mode 100644 index 46fcd2e0b46f948dddc76ae37fa0928aa30e1df3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeI1J!lj`6vyA@zGGuy5u323pn_2l8)1{2As_+uB$YzEI z@XQulIpevnvi4{lunufV2gLl~Vi(cVv8|$`8x-PF-b3`aFb-W760Psg^3syR8TIXSwrqgN=7td4fBl#}DBXphzb>p;>0v39Re zA2n!#&hYhnPi-`4wp4?mO1i2URI7DAs3Timyts7w=lkW}EaliHm8}V0xsC29M|Hec znDWPYMkLlUoa4#0Uxn5S$)VddgQ#{gYu1y!7O5X^F`D=b;#KG8p)m5i_U#{`2Qf`V zkfkv=)GSt(98)xdH!1=7;;jmEz!|;+mV}1$3_Myq`ux81B1IQ5t*0}%)TG;~x#lox zra>o;CL8S^1Y4?(^ZkAo@?~fv#*MTFCoQ2om1q!bKDE*akDp2^INR&*AzQ2;KAy5w zCXc+4@?Z&QJnmJ=2T7RY3@<-lUAulPA9<3NH|xr$VGdR6bk-O>#aG>^sx!Riv(=gW z$|rsQ$aehuCbLGp(mr&G>wZj*SmpZ+?%hWGJKx%orQG0!_iM8iWz4;cBFojXSyd>&xcFQSYmstNF$$tO8+3u{)I$$064;^sw)mpU=;CgMH z_zL1@pNoA2yV!)Tt)gs#gZyQPD3{}i;Xe%V*@aZJ@pNpfh%?y!&Wiy1{I}2l