@@ -4,6 +4,8 @@ import { withRouter } from "react-router-dom"
44import Dropdown from "react-dropdown"
55import "react-dropdown/style.css"
66import "./css/SmartContractSelector.css"
7+ import ProgressButton , { STATE } from "react-progress-button"
8+ import { withCookies } from "react-cookie"
79
810const GreyTopped = glam . div ( {
911 paddingTop : 10 ,
@@ -14,11 +16,13 @@ class ContractAddressDropdown extends Component {
1416 state = {
1517 selectedNotes : this . props . selectedNotes ,
1618 selectedAddress : this . props . selectedAddress ,
19+ connectButtonState : STATE . NOTHING ,
1720 }
1821
1922 _onSelect = selection => {
2023 console . log ( `Detected Selection` )
21- let contractObjects = this . props . fetchObjects ( )
24+ let { contractObjects} = this . props
25+ // let contractObjects = this.props.fetchObjects()
2226 contractObjects . forEach ( obj => {
2327 if ( obj . address === selection . value || obj . notes === selection . value ) {
2428 this . props . onSelect ( { notes : obj . notes , address : obj . address } )
@@ -43,11 +47,34 @@ class ContractAddressDropdown extends Component {
4347 return null
4448 }
4549
46- dropdownDiv = ( ) => {
47- let contractObjects = this . props . fetchObjects ( )
50+ connectProvider = async ( ) =>
51+ this . props . service
52+ . loadWeb3 ( this . props . cookies )
53+ . then ( this . setState ( { connectButtonState : STATE . SUCCESS } ) )
54+
4855
56+ dropdownDiv = ( ) => {
57+ // let contractObjects = this.props.fetchObjects()
58+ let { contractObjects } = this . props
59+ console . log ( `RENDERING ADDRESS DROPDOWN WITH OBJ` , contractObjects )
60+ let network = this . props . service . getCurrentNetwork ( )
61+ if ( ! network ) {
62+ return (
63+ < ProgressButton
64+ style = { {
65+ width : 260 ,
66+ marginTop : 10 ,
67+ color : `white` ,
68+ } }
69+ state = { this . state . connectButtonState }
70+ onClick = { this . connectProvider }
71+ >
72+ Connect Wallet
73+ </ ProgressButton >
74+ )
75+ }
4976 if ( ! contractObjects || contractObjects . length === 0 ) {
50- return < GreyTopped > No Contracts Deployed </ GreyTopped >
77+ return < GreyTopped > Not deployed on { network } </ GreyTopped >
5178 }
5279 return (
5380 < Div >
@@ -67,6 +94,7 @@ class ContractAddressDropdown extends Component {
6794 }
6895 placeholder = 'Nothing Selected'
6996 />
97+ { this . showSelectedDiv ( ) }
7098 </ Div >
7199 )
72100 }
@@ -86,10 +114,9 @@ class ContractAddressDropdown extends Component {
86114 } }
87115 >
88116 { this . dropdownDiv ( ) }
89- { this . showSelectedDiv ( ) }
90117 </ Div >
91118 )
92119 }
93120}
94121
95- export default withRouter ( ContractAddressDropdown )
122+ export default withCookies ( withRouter ( ContractAddressDropdown ) )
0 commit comments