aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/cached-balances.js
blob: 925c453345c2371ac4f0dfa866dca189703cc518 (plain) (blame)
1
2
3
4
5
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const ObservableStore = require('obs-store')
const extend = require('xtend')

/**
 * @typedef {Object} CachedBalancesOptions
 * @property {Object} accountTracker An {@code AccountTracker} reference
 * @property {Function} getNetwork A function to get the current network
 * @property {Object} initState The initial controller state
 */

/**
 * Background controller responsible for maintaining
 * a cache of account balances in local storage
 */
class CachedBalancesController {
  /**
   * Creates a new controller instance
   *
   * @param {CachedBalancesOptions} [opts] Controller configuration parameters
   */
  constructor (opts = {}) {
    const { accountTracker, getNetwork } = opts

    this.accountTracker = accountTracker
    this.getNetwork = getNetwork

    const initState = extend({
      cachedBalances: {},
    }, opts.initState)
    this.store = new ObservableStore(initState)

    this._registerUpdates()
  }

  /**
   * Updates the cachedBalances property for the current network. Cached balances will be updated to those in the passed accounts
   * if balances in the passed accounts are truthy.
   *
   * @param {Object} obj The the recently updated accounts object for the current network
   * @returns {Promise<void>}
   */
  async updateCachedBalances ({ accounts }) {
    const network = await this.getNetwork()
    const balancesToCache = await this._generateBalancesToCache(accounts, network)
    this.store.updateState({
      cachedBalances: balancesToCache,
    })
  }

  _generateBalancesToCache (newAccounts, currentNetwork) {
    const { cachedBalances } = this.store.getState()
    const currentNetworkBalancesToCache = { ...cachedBalances[currentNetwork] }

    Object.keys(newAccounts).forEach(accountID => {
      const account = newAccounts[accountID]

      if (account.balance) {
        currentNetworkBalancesToCache[accountID] = account.balance
      }
    })
    const balancesToCache = {
      ...cachedBalances,
      [currentNetwork]: currentNetworkBalancesToCache,
    }

    return balancesToCache
  }

  /**
   * Sets up listeners and subscriptions which should trigger an update of cached balances. These updates will
   * happen when the current account changes. Which happens on block updates, as well as on network and account
   * selections.
   *
   * @private
   *
   */
  _registerUpdates () {
    const update = this.updateCachedBalances.bind(this)
    this.accountTracker.store.subscribe(update)
  }
}

module.exports = CachedBalancesController
uthor Dan <danjm.com@gmail.com> 2018-03-27 03:24:56 +0800 committer Dan <danjm.com@gmail.com> 2018-03-27 04:07:40 +0800 New-ui changelog updates (March 26)' href='/~lantw44/cgit/dexon-wallet/commit/CHANGELOG.md?id=e5af7e1abdb750a8aa2a69245a6cb2c85943b85d'>e5af7e1a
28a41c20
93622392

ea137777
a3a24d71
16deea39

a3a24d71


e99644af




28a41c20
6c318f23
e91a521b



b4aac16c
9734969e


a4bd7992
9734969e
452c5d05

81fa0742
cb109a82
9734969e
81fa0742
00cd5a34



190389a0

cf6a2f65
190389a0



cf6a2f65
d9486a3c

dae5d085


d9486a3c
b4529549



71be537f

7a820bed
71be537f
a5056a62
7a820bed
9f304e30



0608d157

6106ff02
e6fda855
11a94471
10e75dc4
fa89976c
62b2ce5b


1b8613ed
1f8dd5f0
61cf5e94
5568053c

128b64cc
7e32ba28
5568053c




128b64cc
41fdff41

cd7eaaa7
cab22163
23a928bc
724197b9
6df3261d
4a9dad7c
cd7eaaa7
330ae020

39b700bf
121596bf
cc7e85c0
8cc7e473
24e10e87
c3d85c0a
52bb711f
8cc7e473
622a1f7f

3456efa3
622a1f7f
3456efa3
1ebd5140

408fc0f2

dc4e3ef2

9bb4df46

c391b250

b26c9752

91817573

bd45022a
5ce94e69
80dedcc0
5ce94e69
a7424f0c

926abc12
074f1057
23daca0e
fc7ca17a
926abc12
e564ed8d




56dcf7c0

a71c95b9
d0d082d7
9c45af3e
10011395
d0d082d7
4ed00ea2


0146b55d
0c616956
9f063c32
52bfed5d
8d45b96d

554a3ac4
57b5f152
8d45b96d
4b0e6a0a
d5b0d8af



14d58e63

861bd877
734490c5

b473d440

ea12be2c


a453eb13

8d3fec42

d77e0aff

b46cb3ec
d77e0aff

57b5f152
8a874824

3a3e1511
92e738d1

0424ab3e



c90c904f

1a0c465d

111e67fa
243be92a
6ba448ed
c8736b70
5305d414
899a12cb

1a0c465d
6c318f23

7ff5fd86
a7f02550
2200a114

06889377
42a58918
42a58918
585a3253


42a58918
5e934994


6bff55ba
90272e25
6bff55ba
54ce267a
725e4aae
01f96197

70a61f87
6bff55ba
72bccec4

ad40fc6b
941e5ff1
ad40fc6b
df78020c

1d7781da
e0ccdcd6
1d7781da
f24cfea3

e3a5c368
d7a34514
c90ff284

e3a5c368
27d030b1

c6cfa215


33bdf86a

be7f5bd3
d4849f67

2b409fb6

50fc9c96
2b409fb6
5a925720
c82908e8

2b409fb6
c82908e8
a444326a



10c6aeb2

a444326a
8b1726cc
eb92d65c
8b1726cc
b50c10f3


ab01358a
aa282b4e
ab01358a
dcf02578

948f3880
5e31fc97
a4e567ff
614501e7
2832713a
51c5bebd
5e31fc97
414b9792

2c5b9da0
c6f867ef
eddc8cfe


d97c6533
c7b9e3fb
d97c6533
de967d2d



04a0b949



289fdfb7

52a6b9f1

b87d10ab
52a6b9f1
af8015c1

1503dba5
d3c7ba31

1503dba5
2e7be151

8abd5920
0c011d0f
c7f2fd27

8179f5f8
8abd5920
d7bcd945

db2836a1
5c9a2288
48789f2a
74d15f5c
60855b05
0fd32e67
b3a6df2d
2f4ebea3
d6c14f46
f2cfbda1
ca832959
1b8a4395
74d15f5c
844159cb

50fc9c96
33a70a69
0fb38632
8d8eb0d8
e9e43637
8d8eb0d8
e9c693ea

f9944617
f788ba72
838ffb62

c8f0802a

c92afef9




0fb38632
611cb7ad




d59021f7



76a78fdb

a2064bd1
c1239608
2d739647
10ca3b64
b95f2158
60641612
76a78fdb

7cd42ae9
1203bd15
c1239608
17604f1e

6209224a
3c900245
39f9ffa1
cd2ad173
be5af7cb
6209224a
2a25f994

31c7daee
d389d0ef
44f25cd9

b904fa5d
24737ded
d389d0ef
3ed7205b



ff1a1284



662a646f

17accd3a

d7a2d29e
e921f7f1
f131f59c
17accd3a
c3481f0e
7ddbd1a1
791c8fcc
a21339dd

c3481f0e
6d1fe784


f1beb072

3ae2a829

04e489f4
3ae2a829
c3746e62

daf22168
ddbbc645
c3746e62

daf22168
3b6b06db


6fd7e133
3a1f1b3b
6fd7e133
d41c8ef5

c69ebf34

d9c2f4f5

2ffd42f9
ea59125c
c136cb6c
7d0bfdf0
b6e2eaf7
10040bee
6e6fa703
de0d9af0


1c7e04db
2e446eb5
ea59125c
05346ec3
5edb3db9
761eb495
a35229e8
05346ec3
865764df
1f0a4dd0
761eb495
04e80d36

4033b620
6ef78eb0
6a3b93b0
0b0eec9c

26ae3d20


4033b620
0b0eec9c

26ae3d20



5d827bec

26cd66cb
5d827bec


480c7c5d

e2e8a7cc
50fc9c96
e2b2e6d5




389a104f



99ce68b4

8055113e
81a16fb1
8055113e
a208ed1d

665d6c54
9e585059
665d6c54
9203b8c3

ac6a2b4b
50fc9c96

a9bdc76e

68e27e61
3363a38b
55a55754
b9a365a8

d2fb48f8
0fab2208
6f7c23fd
3f2945dc

efde16aa
05e62cbc
6f8370fc
91105474
e1d6a1ea
5ea7d738

4f3ba6e0
5ea7d738


3632173a
44a2f2ad

36c82488
92ddcba7
36c82488
d9f8a8f9





aefc346a
1ddc7625

e8a83026
8eb91e89
6ae2400e
17669e4a
6dad4f1f
8eb91e89
a4eadddd

1d0abc47
b6b4be61
a4eadddd
4eef2c57
4a019701

6f39924e
7068d2e7
50fc9c96
18cf6357
b8acdfca

4366f72f
9b8c9707
b3613232
f2497c5a

bda64ab1
7140c04e
f31fef03
70f3d24e
91f43fa2
cc23158b
91f43fa2
58640445


91a8977d
cc23158b
91a8977d
6ee22e66


c7d10aff
55364b6e
e1ece0f0
40baf0b7


89780bd2
6ee22e66
8ef75216

f28de37a
da611eb3
8ef75216
769bd8e2
f28de37a
b6bbe2d7




9d5cdbcb


bc33c88a

7293c67f
e826eb93
8df00515

17481ff6

8df00515
17481ff6
03094091


3da0d614


b5085419



ebf86f93

ece1ecb9
e75a1d63
5e38f48f
01618a88
2564c0c5
a1e9b951
50fc9c96
2f98d5bc
e75a1d63
c2a1b442



8b37bcf1

e39513ff
a6e3357d
f9f821e7
8b37bcf1
e39513ff
bb8241f7

642e84da
bb8241f7
ca4127dd
bb8241f7
ca4127dd
a9b390c5



340d12f0

050d0aec
f57cbe59

15c8680e
c27ad468
50fc9c96
6041d615
df824c0c
31e0a349

98dab0ff
e3e5538d
7d40f299
d53b0564
7d40f299
e5f2c1a8

31d6d5c5
df824c0c
f42723c9
7dcb3c64
e826eb93
f42723c9
3a489baa



019581bd

5d83b917
5ceed48d
5d83b917
43784e21

0eb7354c
c6ec3fc7
43784e21
f8f8e78c
c6ec3fc7
5d93e8fa

fcd523ab

cdd7e405
0bbfedc2
cdd7e405
5567ea8d

2697e1ba
1d8d8384
2697e1ba
3b80a043

dbc90082
539fe3e9
1f347c22
ad803125

97e38b49
539fe3e9
a446be23

53eefc1e
04c4dad8
ec5adf01
acdd40e3
28617d87
ecb0f976
f26c47a3
a72aad19

8258ab2d
76c47353

8465be34
0b3737ed

57c89228
3ae479f5
db3f7334
3ae479f5
757a3ce6

cbcc0438

204cb7f1
661d9bff

9f5b6275
86a1eaad
c6187b08
e4956c31
cbcc0438
24372845





973aa4fd
b3b49838

73869ea2

c152f987

856a7c84
73869ea2
c152f987
d19c286e

d34b7033


f599f9ad
6ee45a74
65f9f997
0384f0cb
5efef313

e9407777
d5c378b0
5efef313
d5c378b0
8dcba9a6

b9007ee8
9cc04be5
b9007ee8
9cc04be5
01e63d41

73ad7173
f69721a9

b81b3048
73ad7173
7f4929a2

d5e4ceb0
5669f443

2683d1f4
d8c4af5f
d5e4ceb0
33f9aabf

60270de5




4386fdd0
8efd30ad
0e6b62a9
7f77fe1a

e29bac12

57d6ad2a




c7a491d7

b430cbd0
8bfa40d2
c7a491d7
b430cbd0
39403eb7

d8bee4f5


366f45d4

46e100f5
366f45d4
37dc13ce
cad9a5e6
f92189a7
ebb0aac7
edf4e2bc
356da540
46e100f5
fcab1618

88ed546a


82ac8bde
9360e335
a5d024c7
dcbf17af
8421c97d


98816522
88ed546a
fcab1618
652c1d96
0e39110f

2f09ab79
28f14661
2f09ab79
c5dfd2e3


33b344d2
0e39110f
fcab1618
81fc1e5f
9f1438b8
8cb4c044
e10480de
33dc6853

9f1438b8
da5bf684

bfd732e7

8fde1d69
bfd732e7
0fb997c5

8258ab2d
874d9c1a


0fb997c5

8258ab2d
cc05be2f













84789d67


1
2
3
4
5
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994

           
                 
 
                                                                               
                                      
                                                          
                                                            
                                           
 

                        






                                                                                                    
 

                                                                         
                                                                                                    
                               
 

                        
                                                                                                                                   

                                            

                        
                                                                                          
 

                        

                                                     
 

                        

                                                                                       
                                                                              
                                                                                                            
 

                        
                                                  
                                                                          





                                                                       
 

                        
                                                                                                                                                                                                                                                                                                                                                                                                        
                                             

                                                                     


                                                                             




                                                           
                                                                   
 



                                         
                                  


                                                                             
                                     
 

                  
                                                                                                     
                                                    
                                                             
 



                                                            

                  
                                                            



                                                                       
 

                  


                                                        
 



                                        

                   
                                                                     
                                                         
                                                                                         
 



                                    

                  
                                    
                                           
                                                
                                      
 


                                 
                                                       
                                                                
 

                   
                                                         
                                                               




                                                                                   
 

                   
                                                                                                                    
                                                  
                        
                                                                                                                                         
                                                              
                                       
 

                  
                                                                                                                                                               
                                                                                
                                                                                                                     
                                                       
                                                                                                        
                                                                                 
                                                                                                    
 

                    
                                                 
                                                              
 

                   

                                                                    

                   

                                                                                                               

                   

                                                                   

                    
                                                                 
                                                                            
                                       
 

                    
                                                                                 
                                      
                                                                         
                                                                                               
 




                                                                                

                    
                                                        
                                                                      
                                                                                                       
                                                                             
 


                                                           
                                                                                                   
                                                                                                            
                                                 
 

                   
                                                                   
                                                                      
                                                                                                                       
 



                                           

                   
                                                                                              

                                                           

                   


                                                                    

                   

                                 

                   
                                                                                                

                                                                      
 

                   
                                                               

                                                                                               



                             

                   

                                               
                                                              
                                                           
                                                                              
                             
                                                 

                                                                                     
 

                   
                                                         
                                             

                                                                                                 
                                                                                           
 
 


                                                                                           
 


                                               
                                              
                                                  
                                                                 
                                     
                                                                                    

                                                   
                                                                               
 

                   
                                                                            
                                                       
 

                   
                                                                                                  
                                                          
 

                  
                                                                              
                                                               

                                                          
 

                  


                        

                  
                             

                                                                                           

                  
                                                        
                                                                     
 

                  
                                                       
 



                                                            

                  
                               
                                                                       
                                                                                                  
 


                                                                                       
                                                                                      
                                                                                                                
 

                  
                                                                                       
                                                  
                                                          
                                                                                                                                             
                                                                          
                                      
 

                  
                                              
 


                                               
                                                     
                                                                                          
 



                                                               



                                                                                         

                 

                                                                                
                                                                                                                          
 

                 
                                                                                             

                                                                
 

                  
                                                                                
                                                                                                        

                                                           
                                                                                   
 

                  
                                            
                                                             
                                          
                                    
                                                            
                                                                                 
                                                                           
                                                
                                   
                                                                               
                                                 
                                                 
 

                  
                                                  
                                                    
                                        
                                                   
                             
 

                 
                                                                                                           
 

                 

                                              




                                                                   
 




                                                                                                      



                                    

                  
                                                             
                                                            
                                         
                                                                 
                                                       
                                                                                                                        

                                                                                                                                 
                                                             
                                                                        
 

                  
                                                     
                                           
                                                                                     
                                                                                       
                                                                                                                         
 

                  
                                                            
                     

                                    
                                                            
                                                                      
 



                              



                                                                            

                 

                                                        
                                                                
                                           
                                                                       
 
                  
 
                     

                                                                                       
                  


                                               

                  

                                                         
                                                                                                     
 

                  
                                    
                                                  

                                        
 


                                                         
                                                         
                                  
 

                  

                                                                                                                            

                  
                                                                    
                                                     
                                                                                          
                                                            
                                                                                                                                                                                      
                                                                                                  
                            


                                                                          
                                             
                                                                                                                  
 
                 
 
                                                                  
                                   
                                        
                                                                               
                                                          
 

                  
                                        
                                     
                                          

                                                                                                


                                                                                                                                                                                                    
 

                                                                                                



                                                                                                                                                                                                    

                 
                                           


                                                              

                                                                                                   
                                                                
                                                                                                                                    




                                    



                           

                  
                                                
                                                                                                                                             
 

                  
                                                 
                                                                                                   
 

                  
                                                                                                                    

                                                                                                                                                            

                                                          
                                                               
                                                   
                                                                                                       

                                                         
                                                         
                                                                                     
 

                    
                                                          
                                 
                                                                             
                                                
 

                    
                                                     


                                                
 

                     
                                                               
                                                                              
 





                                                                                 
 

                    
                                                        
                                                                                                         
                                                                                                   
                                               
                                                      
 

                    
                                                            
                                                                 
                                                               
 

                   
                                                          
                                                              
                                                              
 

                    
                                            
                                      
                                                                            

                                                                                           
                                                                     
 
                    
 
                                                                             
                                                                                 
 


                                                
                                                       
                                                                
 


                                              
                                                                                              
                                                                        
                                                                            


                                                            
                                                                         
 

                   
                                                                                 
                                                                                    
                                                                         
                                                                                                           
 




                                                                         


                                                          

                                                                                             
                                                                                            
 

                    

                                                                              
                                                                                           
 


                                              


                                                                    



                                                            

                    
                                                                                           
                                           
                                                                                                 
                                          
                      
                                                                                              
                                                                                                                         
                                                                                                
 



                                                     

                    
                                                                                              
                                                                        
                                                                                                                                  
                                    
 

                    
                                                                         
                                                                                                         
                                                                             
                                          
 



                                                  

                   
                                                                

                                                          
                                                                                  
                                                               
                             
                                                                         
 

                   
                                             
                                            
                                                                             
                               
 

                   
                      
                                                  
                    
                                             
                                             
 



                                                                    

                   
                                       
                                                         
 

                   
                                                                                 
                                                                                                          
                                                                                                             
                                                  
 

                   

                                          
                                                                                       
                                            
 

                   
                                                                                                                         
                                                          
 

                   
                                                     
                                                             
                                                           

                                                                                           
                                                                        
 

                   
                               
                                    
                                                
                                                       
                                     
                                                       
                                                                                                         

                                                                          
 

                   
                               

                                                 
                                                                       
                                                                                          
                                                       
 

                   

                                                       
                                                                                                      

                                                                       
                                            
                                                 
                                                                            
                                                        
 





                                                       
                                                            

                                               

                   

                                 
                          
                                                
 

                   


                                                                        
                                                       
                                                               
                                                                 
 

                   
                        
                                                                    
                       
 

                   
                                  
                                            
                                                                
 

                   
                                                                             

                                                                                   
                                                               
 

                   
                                            

                                                                
                                                                             
                                                           
 

                   




                                                                                       
                                         
                                             
 

                   

                                       




                                             

                   
                                                                                               
                                             
                                      
 

                   


                                                                     

                   
                                      
                                                                    
                                              
                                                                                            
                                              
                                                
                                             
                                                                 
 

                   


                                                                                                              
                                                                                            
                                                                                    
                              
                                                                                                                                            


                                                                                                   
                                                    
 
                   
 

                                                                                                 
                                                
                                                                                
                                                                                                               


                                                      
                                                                         
 
                   
 
                                                                                                           
                                                                               
                                                                         

                                                                    
 

                   

                                                                                     
                                                                   
 

                   
                                                                 


                                                         

                                                                                                         
 













                                                                                 


                                                      
# Changelog

## Current Master

- Correctly format currency conversion for locally selected preferred currency.
- Improved performance of 3D fox logo.
- Fetch token prices based on contract address, not symbol
- Fix bug that prevents setting language locale in settings.
- Show checksum addresses throughout the UI

## 4.5.5 Fri Apr 06 2018

- Graceful handling of unknown keys in txParams
- Fixes buggy handling of historical transactions with unknown keys in txParams
- Fix link for 'Learn More' in the Add Token Screen to open to a new tab.
- Fix Download State Logs button [#3791](https://github.com/MetaMask/metamask-extension/issues/3791)
- Enhanced migration error handling + reporting

## 4.5.4 (aborted) Thu Apr 05 2018

- Graceful handling of unknown keys in txParams
- Fix link for 'Learn More' in the Add Token Screen to open to a new tab.
- Fix Download State Logs button [#3791](https://github.com/MetaMask/metamask-extension/issues/3791)
- Fix migration error reporting

## 4.5.3 Wed Apr 04 2018

- Fix bug where checksum address are messing with balance issue [#3843](https://github.com/MetaMask/metamask-extension/issues/3843)
- new ui: fix the confirm transaction screen

## 4.5.2 Wed Apr 04 2018

- Fix overly strict validation where transactions were rejected with hex encoded "chainId"

## 4.5.1 Tue Apr 03 2018

- Fix default network (should be mainnet not Rinkeby)
- Fix Sentry automated error reporting endpoint

## 4.5.0 Mon Apr 02 2018

- (beta ui) Internationalization: Select your preferred language in the settings screen
- Internationalization: various locale improvements
- Fix bug where the "Reset account" feature would not clear the network cache.
- Increase maximum gas limit, to allow very gas heavy transactions, since block gas limits have been stable.

## 4.4.0 Mon Mar 26 2018

- Internationalization: Taiwanese, Thai, Slovenian
- Fixes bug where MetaMask would not open once its storage grew too large.
- Updates design of new-ui Add Token screen
- New-ui can send to ens addresses
- Update new-ui button styles
- Signed-type-data notification handles long messages
- Popup extension in new-ui uses new on-boarding designs
- Buy ether step of new-ui on-boarding uses new buy ether modal designs

## 4.3.0 Wed Mar 21 2018

- (beta) Add internationalization support! Includes translations for 13 (!!) new languages: French, Spanish, Italian, German, Dutch, Portuguese, Japanese, Korean, Vietnamese, Mandarin, Hindi, Tagalog, and Russian! Select "Try Beta" in the menu to take them for a spin. Read more about the community effort [here](https://medium.com/gitcoin/metamask-internationalizes-via-gitcoin-bf1390c0301c)
- No longer uses nonces specified by the dapp
- Will now throw an error if the `to` field in txParams is not valid.
- Will strip null values from the `to` field.
- (beta) No longer shows token confirmation screen when performing a non-send
- (beta) Fixes bug where tx data was nullified when repricing a tx
- Fix flashing Login screen after logging in or restoring from seed phrase.
- Increase tap areas for menu buttons on mobile
- Change all fonts in new-ui onboarding to Roboto, size 400
- Add a welcome screen to new-ui onboarding flow
- Make new-ui create password screen responsive
- Hide network dropdown before account is initialized
- Fix bug that could prevent MetaMask from saving the latest vault.

## 4.2.0 Tue Mar 06 2018

- Replace "Loose" wording to "Imported".
- Replace "Unlock" wording with "Log In".
- Add Imported Account disclaimer.
- Allow adding custom tokens to classic ui when balance is 0
- Allow editing of symbol and decimal info when adding custom token in new-ui
- NewUI shapeshift form can select all coins (not just BTC)
- Add most of Microsoft Edge support.

## 4.1.3 2018-2-28

- Ensure MetaMask's inpage provider is named MetamaskInpageProvider to keep some sites from breaking.
- Add retry transaction button back into classic ui.
- Add network dropdown styles to support long custom RPC urls

## 4.1.2 2018-2-28

- Actually includes all the fixes mentioned in 4.1.1 (sorry)

## 4.1.1 2018-2-28

- Fix "Add Token" screen referencing missing token logo urls
- Prevent user from switching network during signature request
- Fix misleading language "Contract Published" -> "Contract Deployment"
- Fix cancel button on "Buy Eth" screen
- Improve new-ui onboarding flow style

## 4.1.0 2018-2-27

- Report failed txs to Sentry with more specific message
- Fix internal feature flags being sometimes undefined
- Standardized license to MIT

## 4.0.0 2018-2-22

- Introduce new MetaMask user interface.

## 3.14.2 2018-2-15

- Fix bug where log subscriptions would break when switching network.
- Fix bug where storage values were cached across blocks.
- Add MetaMask light client [testing container](https://github.com/MetaMask/mesh-testing)

## 3.14.1 2018-2-1

- Further fix scrolling for Firefox.

## 3.14.0 2018-2-1

- Removed unneeded data from storage
- Add a "reset account" feature to Settings
- Add warning for importing some kinds of files.
- Scrollable Setting view for Firefox.

## 3.13.8 2018-1-29

- Fix provider for Kovan network.
- Bump limit for EventEmitter listeners before warning.
- Display Error when empty string is entered as a token address.

## 3.13.7 2018-1-22

- Add ability to bypass gas estimation loading indicator.
- Forward failed transactions to Sentry error reporting service
- Re-add changes from 3.13.5

## 3.13.6 2017-1-18

- Roll back changes to 3.13.4 to fix some issues with the new Infura REST provider.

## 3.13.5 2018-1-16

- Estimating gas limit for simple ether sends now faster & cheaper, by avoiding VM usage on recipients with no code.
- Add an extra px to address for Firefox clipping.
- Fix Firefox scrollbar.
- Open metamask popup for transaction confirmation before gas estimation finishes and add a loading screen over transaction confirmation.
- Fix bug that prevented eth_signTypedData from signing bytes.
- Further improve gas price estimation.

## 3.13.4 2018-1-9

- Remove recipient field if application initializes a tx with an empty string, or 0x, and tx data. Throw an error with the same condition, but without tx data.
- Improve gas price suggestion to be closer to the lowest that will be accepted.
- Throw an error if a application tries to submit a tx whose value is a decimal, and inform that it should be in wei.
- Fix bug that prevented updating custom token details.
- No longer mark long-pending transactions as failed, since we now have button to retry with higher gas.
- Fix rounding error when specifying an ether amount that has too much precision.
- Fix bug where incorrectly inputting seed phrase would prevent any future attempts from succeeding.

## 3.13.3 2017-12-14

- Show tokens that are held that have no balance.
- Reduce load on Infura by using a new block polling endpoint.

## 3.13.2 2017-12-9

- Reduce new block polling interval to 8000 ms, to ease server load.

## 3.13.1 2017-12-7

- Allow Dapps to specify a transaction nonce, allowing dapps to propose resubmit and force-cancel transactions.

## 3.13.0 2017-12-7

- Allow resubmitting transactions that are taking long to complete.

## 3.12.1 2017-11-29

- Fix bug where a user could be shown two different seed phrases.
- Detect when multiple web3 extensions are active, and provide useful error.
- Adds notice about seed phrase backup.

## 3.12.0 2017-10-25

- Add support for alternative ENS TLDs (Ethereum Name Service Top-Level Domains).
- Lower minimum gas price to 0.1 GWEI.
- Remove web3 injection message from production (thanks to @ChainsawBaby)
- Add additional debugging info to our state logs, specifically OS version and browser version.

## 3.11.2 2017-10-21

- Fix bug where reject button would sometimes not work.
- Fixed bug where sometimes MetaMask's connection to a page would be unreliable.

## 3.11.1 2017-10-20

- Fix bug where log filters were not populated correctly
- Fix bug where web3 API was sometimes injected after the page loaded.
- Fix bug where first account was sometimes not selected correctly after creating or restoring a vault.
- Fix bug where imported accounts could not use new eth_signTypedData method.

## 3.11.0 2017-10-11

- Add support for new eth_signTypedData method per EIP 712.
- Fix bug where some transactions would be shown as pending forever, even after successfully mined.
- Fix bug where a transaction might be shown as pending forever if another tx with the same nonce was mined.
- Fix link to support article on token addresses.

## 3.10.9 2017-10-5

- Only rebrodcast transactions for a day not a days worth of blocks
- Remove Slack link from info page, since it is a big phishing target.
- Stop computing balance based on pending transactions, to avoid edge case where users are unable to send transactions.

## 3.10.8 2017-9-28

- Fixed usage of new currency fetching API.

## 3.10.7 2017-9-28

- Fixed bug where sometimes the current account was not correctly set and exposed to web apps.
- Added AUD, HKD, SGD, IDR, PHP to currency conversion list

## 3.10.6 2017-9-27

- Fix bug where newly created accounts were not selected.
- Fix bug where selected account was not persisted between lockings.

## 3.10.5 2017-9-27

- Fix block gas limit estimation.

## 3.10.4 2017-9-27

- Fix bug that could mis-render token balances when very small. (Not actually included in 3.9.9)
- Fix memory leak warning.
- Fix bug where new event filters would not include historical events.

## 3.10.3 2017-9-21

- Fix bug where metamask-dapp connections are lost on rpc error
- Fix bug that would sometimes display transactions as failed that could be successfully mined.

## 3.10.2 2017-9-18

rollback to 3.10.0 due to bug

## 3.10.1 2017-9-18

- Add ability to export private keys as a file.
- Add ability to export seed words as a file.
- Changed state logs to a file download than a clipboard copy.
- Add specific error for failed recipient address checksum.
- Fixed a long standing memory leak associated with filters installed by dapps
- Fix link to support center.
- Fixed tooltip icon locations to avoid overflow.
- Warn users when a dapp proposes a high gas limit (90% of blockGasLimit or higher
- Sort currencies by currency name (thanks to strelok1: https://github.com/strelok1).

## 3.10.0 2017-9-11

- Readded loose keyring label back into the account list.
- Remove cryptonator from chrome permissions.
- Add info on token contract addresses.
- Add validation preventing users from inputting their own addresses as token tracking addresses.
- Added button to reject all transactions (thanks to davidp94! https://github.com/davidp94)


## 3.9.13 2017-9-8

- Changed the way we initialize the inpage provider to fix a bug affecting some developers.

## 3.9.12 2017-9-6

- Fix bug that prevented Web3 1.0 compatibility
- Make eth_sign deprecation warning less noisy
- Add useful link to eth_sign deprecation warning.
- Fix bug with network version serialization over synchronous RPC
- Add MetaMask version to state logs.
- Add the total amount of tokens when multiple tokens are added under the token list
- Use HTTPS links for Etherscan.
- Update Support center link to new one with HTTPS.
- Make web3 deprecation notice more useful by linking to a descriptive article.

## 3.9.11 2017-8-24

- Fix nonce calculation bug that would sometimes generate very wrong nonces.
- Give up resubmitting a transaction after 3500 blocks.

## 3.9.10 2017-8-23

- Improve nonce calculation, to prevent bug where people are unable to send transactions reliably.
- Remove link to eth-tx-viz from identicons in tx history.

## 3.9.9 2017-8-18

- Fix bug where some transaction submission errors would show an empty screen.
- Fix bug that could mis-render token balances when very small.
- Fix formatting of eth_sign "Sign Message" view.
- Add deprecation warning to eth_sign "Sign Message" view.

## 3.9.8 2017-8-16

- Reenable token list.
- Remove default tokens.

## 3.9.7 2017-8-15

- hotfix - disable token list
- Added a deprecation warning for web3 https://github.com/ethereum/mist/releases/tag/v0.9.0

## 3.9.6 2017-8-09

- Replace account screen with an account drop-down menu.
- Replace account buttons with a new account-specific drop-down menu.

## 3.9.5 2017-8-04

- Improved phishing detection configuration update rate

## 3.9.4 2017-8-03

- Fixed bug that prevented transactions from being rejected.

## 3.9.3 2017-8-03

- Add support for EGO ujo token
- Continuously update blacklist for known phishing sites in background.
- Automatically detect suspicious URLs too similar to common phishing targets, and blacklist them.

## 3.9.2 2017-7-26

- Fix bugs that could sometimes result in failed transactions after switching networks.
- Include stack traces in txMeta's to better understand the life cycle of transactions
- Enhance blacklister functionality to include levenshtein logic. (credit to @sogoiii and @409H for their help!)

## 3.9.1 2017-7-19

- No longer automatically request 1 ropsten ether for the first account in a new vault.
- Now redirects from known malicious sites faster.
- Added a link to our new support page to the help screen.
- Fixed bug where a new transaction would be shown over the current transaction, creating a possible timing attack against user confirmation.
- Fixed bug in nonce tracker where an incorrect nonce would be calculated.
- Lowered minimum gas price to 1 Gwei.

## 3.9.0 2017-7-12

- Now detects and blocks known phishing sites.

## 3.8.6 2017-7-11

- Make transaction resubmission more resilient.
- No longer validate nonce client-side in retry loop.
- Fix bug where insufficient balance error was sometimes shown on successful transactions.

## 3.8.5 2017-7-7

- Fix transaction resubmit logic to fail slightly less eagerly.

## 3.8.4 2017-7-7

- Improve transaction resubmit logic to fail more eagerly when a user would expect it to.

## 3.8.3 2017-7-6

- Re-enable default token list.
- Add origin header to dapp-bound requests to allow providers to throttle sites.
- Fix bug that could sometimes resubmit a transaction that had been stalled due to low balance after balance was restored.

## 3.8.2 2017-7-3

- No longer show network loading indication on config screen, to allow selecting custom RPCs.
- Visually indicate that network spinner is a menu.
- Indicate what network is being searched for when disconnected.

## 3.8.1 2017-6-30

- Temporarily disabled loading popular tokens by default to improve performance.
- Remove SEND token button until a better token sending form can be built, due to some precision issues.
- Fix precision bug in token balances.
- Cache token symbol and precisions to reduce network load.
- Transpile some newer JavaScript, restores compatibility with some older browsers.

## 3.8.0 2017-6-28

- No longer stop rebroadcasting transactions
- Add list of popular tokens held to the account detail view.
- Add ability to add Tokens to token list.
- Add a warning to JSON file import.
- Add "send" link to token list, which goes to TokenFactory.
- Fix bug where slowly mined txs would sometimes be incorrectly marked as failed.
- Fix bug where badge count did not reflect personal_sign pending messages.
- Seed word confirmation wording is now scarier.
- Fix error for invalid seed words.
- Prevent users from submitting two duplicate transactions by disabling submit.
- Allow Dapps to specify gas price as hex string.
- Add button for copying state logs to clipboard.

## 3.7.8 2017-6-12

- Add an `ethereum:` prefix to the QR code address
- The default network on installation is now MainNet
- Fix currency API URL from cryptonator.
- Update gasLimit params with every new block seen.
- Fix ENS resolver symbol UI.

## 3.7.7 2017-6-8

- Fix bug where metamask would show old data after computer being asleep or disconnected from the internet.

## 3.7.6 2017-6-5

- Fix bug that prevented publishing contracts.

## 3.7.5 2017-6-5

- Prevent users from sending to the `0x0` address.
- Provide useful errors when entering bad characters in ENS name.
- Add ability to copy addresses from transaction confirmation view.

## 3.7.4 2017-6-2

- Fix bug with inflight cache that caused some block lookups to return bad values (affected OasisDex).
- Fixed bug with gas limit calculation that would sometimes create unsubmittable gas limits.

## 3.7.3 2017-6-1

- Rebuilt to fix cache clearing bug.

## 3.7.2 2017-5-31

- Now when switching networks sites that use web3 will reload
- Now when switching networks the extension does not restart
- Cleanup decimal bugs in our gas inputs.
- Fix bug where submit button was enabled for invalid gas inputs.
- Now enforce 95% of block's gasLimit to protect users.
- Removing provider-engine from the inpage provider. This fixes some error handling inconsistencies introduced in 3.7.0.
- Added "inflight cache", which prevents identical requests from clogging up the network, dramatically improving ENS performance.
- Fixed bug where filter subscriptions would sometimes fail to unsubscribe.
- Some contracts will now display logos instead of jazzicons.
- Some contracts will now have names displayed in the confirmation view.

## 3.7.0 2017-5-23

- Add Transaction Number (nonce) to transaction list.
- Label the pending tx icon with a tooltip.
- Fix bug where website filters would pile up and not deallocate when leaving a site.
- Continually resubmit pending txs for a period of time to ensure successful broadcast.
- ENS names will no longer resolve to their owner if no resolver is set. Resolvers must be explicitly set and configured.

## 3.6.5 2017-5-17

- Fix bug where edited gas parameters would not take effect.
- Trim currency list.
- Enable decimals in our gas prices.
- Fix reset button.
- Fix event filter bug introduced by newer versions of Geth.
- Fix bug where decimals in gas inputs could result in strange values.

## 3.6.4 2017-5-8

- Fix main-net ENS resolution.

## 3.6.3 2017-5-8

- Fix bug that could stop newer versions of Geth from working with MetaMask.

## 3.6.2 2017-5-8

- Input gas price in Gwei.
- Enforce Safe Gas Minimum recommended by EthGasStation.
- Fix bug where block-tracker could stop polling for new blocks.
- Reduce UI size by removing internal web3.
- Fix bug where gas parameters would not properly update on adjustment.

## 3.6.1 2017-4-30

- Made fox less nosy.
- Fix bug where error was reported in debugger console when Chrome opened a new window.

## 3.6.0 2017-4-26

- Add Rinkeby Test Network to our network list.

## 3.5.4 2017-4-25

- Fix occasional nonce tracking issue.
- Fix bug where some events would not be emitted by web3.
- Fix bug where an error would be thrown when composing signatures for networks with large ID values.

## 3.5.3 2017-4-24

- Popup new transactions in Firefox.
- Fix transition issue from account detail screen.
- Revise buy screen for more modularity.
- Fixed some other small bugs.

## 3.5.2 2017-3-28

- Fix bug where gas estimate totals were sometimes wrong.
- Add link to Kovan Test Faucet instructions on buy view.
- Inject web3 into loaded iFrames.

## 3.5.1 2017-3-27

- Fix edge case where users were unable to enable the notice button if notices were short enough to not require a scrollbar.

## 3.5.0 2017-3-27

- Add better error messages for when a transaction fails on approval
- Allow sending to ENS names in send form on Ropsten.
- Added an address book functionality that remembers the last 15 unique addresses sent to.
- Can now change network to custom RPC URL from lock screen.
- Removed support for old, lightwallet based vault. Users who have not opened app in over a month will need to recover with their seed phrase. This will allow Firefox support sooner.
- Fixed bug where spinner wouldn't disappear on incorrect password submission on seed word reveal.
- Polish the private key UI.
- Enforce minimum values for gas price and gas limit.
- Fix bug where total gas was sometimes not live-updated.
- Fix bug where editing gas value could have some abrupt behaviors (#1233)
- Add Kovan as an option on our network list.