@@ -4,14 +4,21 @@ const h = require('react-hyperscript')
4
4
const inherits = require ( 'util' ) . inherits
5
5
const connect = require ( 'react-redux' ) . connect
6
6
const actions = require ( '../../actions' )
7
-
7
+ const genAccountLink = require ( 'etherscan-link' ) . createAccountLink
8
+ const copyToClipboard = require ( 'copy-to-clipboard' )
9
+ const { Menu, Item, CloseArea } = require ( './components/menu' )
8
10
9
11
TokenMenuDropdown . contextTypes = {
10
12
t : PropTypes . func ,
11
13
}
12
14
13
- module . exports = connect ( null , mapDispatchToProps ) ( TokenMenuDropdown )
15
+ module . exports = connect ( mapStateToProps , mapDispatchToProps ) ( TokenMenuDropdown )
14
16
17
+ function mapStateToProps ( state ) {
18
+ return {
19
+ network : state . metamask . network ,
20
+ }
21
+ }
15
22
16
23
function mapDispatchToProps ( dispatch ) {
17
24
return {
@@ -37,22 +44,34 @@ TokenMenuDropdown.prototype.onClose = function (e) {
37
44
TokenMenuDropdown . prototype . render = function ( ) {
38
45
const { showHideTokenConfirmationModal } = this . props
39
46
40
- return h ( 'div. token-menu-dropdown', { } , [
41
- h ( 'div.token-menu-dropdown__close-area' , {
47
+ return h ( Menu , { className : ' token-menu-dropdown', isShowing : true } , [
48
+ h ( CloseArea , {
42
49
onClick : this . onClose ,
43
50
} ) ,
44
- h ( 'div.token-menu-dropdown__container' , { } , [
45
- h ( 'div.token-menu-dropdown__options' , { } , [
46
-
47
- h ( 'div.token-menu-dropdown__option' , {
48
- onClick : ( e ) => {
49
- e . stopPropagation ( )
50
- showHideTokenConfirmationModal ( this . props . token )
51
- this . props . onClose ( )
52
- } ,
53
- } , this . context . t ( 'hideToken' ) ) ,
54
-
55
- ] ) ,
56
- ] ) ,
51
+ h ( Item , {
52
+ onClick : ( e ) => {
53
+ e . stopPropagation ( )
54
+ showHideTokenConfirmationModal ( this . props . token )
55
+ this . props . onClose ( )
56
+ } ,
57
+ text : this . context . t ( 'hideToken' ) ,
58
+ } ) ,
59
+ h ( Item , {
60
+ onClick : ( e ) => {
61
+ e . stopPropagation ( )
62
+ copyToClipboard ( this . props . token . address )
63
+ this . props . onClose ( )
64
+ } ,
65
+ text : this . context . t ( 'copyContractAddress' ) ,
66
+ } ) ,
67
+ h ( Item , {
68
+ onClick : ( e ) => {
69
+ e . stopPropagation ( )
70
+ const url = genAccountLink ( this . props . token . address , this . props . network )
71
+ global . platform . openWindow ( { url } )
72
+ this . props . onClose ( )
73
+ } ,
74
+ text : this . context . t ( 'viewOnEtherscan' ) ,
75
+ } ) ,
57
76
] )
58
77
}
0 commit comments