@@ -3,7 +3,8 @@ import React from 'react'
4import { Code, H3 } from './Base'
4import { Code, H3 } from './Base'
5import { Button } from './Base'
5import { Button } from './Base'
6−import { CheckboxButton, Input, InnerLabel } from './Base'
6+import { CheckboxButton, Input, InnerLabel,
7+ InnerLabelDropdown, DropdownItem } from './Base'
7import { Warning } from '../components/Base'
8import { Warning } from '../components/Base'
9import { addressFromSecp256k1Public } from '../lib/wallet'
10import { addressFromSecp256k1Public } from '../lib/wallet'
@@ -28,10 +29,12 @@ class StatelessTransaction extends React.Component {
28 showGasDetails: false,
29 showGasDetails: false,
29 userApproval: false,
30 userApproval: false,
30 chainId: '',
31 chainId: '',
32+ chainDropdownOpen: false,
31 nonce: '',
34 nonce: '',
32 stx: Nothing(),
35 stx: Nothing(),
33 txn: Nothing(),
36 txn: Nothing(),
34− txError: Nothing(),
37+ txError: Nothing()
37 this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
40 this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
@@ -46,6 +49,10 @@ class StatelessTransaction extends React.Component {
46 this.setGasLimit = this.setGasLimit.bind(this)
49 this.setGasLimit = this.setGasLimit.bind(this)
47 this.rangeChange = this.rangeChange.bind(this)
50 this.rangeChange = this.rangeChange.bind(this)
48 this.toggleGasDetails = this.toggleGasDetails.bind(this)
51 this.toggleGasDetails = this.toggleGasDetails.bind(this)
52+ this.toggleChainDropdown = this.toggleChainDropdown.bind(this)
53+ this.closeChainDropdown = this.closeChainDropdown.bind(this)
54+ this.selectChain = this.selectChain.bind(this)
55+ this.openCustomChain = this.openCustomChain.bind(this)
51 componentDidMount() {
58 componentDidMount() {
@@ -106,6 +113,33 @@ class StatelessTransaction extends React.Component {
118+ chainDropdownOpen: false,
123+ toggleChainDropdown() {
125+ chainDropdownOpen: !this.state.chainDropdownOpen
129+ closeChainDropdown() {
131+ chainDropdownOpen: false
135+ selectChain(chainId) {
138+ chainDropdownOpen: false,
109 setUserApproval(){
143 setUserApproval(){
110 const {state} = this
144 const {state} = this
111 this.setState({ userApproval: !state.userApproval })
145 this.setState({ userApproval: !state.userApproval })
@@ -188,10 +222,11 @@ class StatelessTransaction extends React.Component {
188 render() {
222 render() {
189 const { web3, canGenerate } = this.props
223 const { web3, canGenerate } = this.props
190 const { gasPrice, gasLimit, nonce, chainId,
224 const { gasPrice, gasLimit, nonce, chainId,
191− txn, stx, userApproval, showGasDetails } = this.state
225+ txn, stx, userApproval, showGasDetails,
226+ customChain, chainDropdownOpen } = this.state
193 const { setNonce, setChainId, setGasLimit, setGasPrice, toggleGasDetails,
228 const { setNonce, setChainId, setGasLimit, setGasPrice, toggleGasDetails,
194− setUserApproval, sendTxn, createUnsignedTxn } = this
229+ setUserApproval, sendTxn, createUnsignedTxn, selectChain } = this
196 const { state } = this
231 const { state } = this
@@ -294,7 +329,7 @@ class StatelessTransaction extends React.Component {
295 const nonceDialogue =
330 const nonceDialogue =
297− className={ 'mono mt-4' }
332+ className={ 'mono mt-4 mb-4' }
298 prop-size={ 'md' }
333 prop-size={ 'md' }
299 prop-format={ 'innerLabel' }
334 prop-format={ 'innerLabel' }
300 value={ nonce }
335 value={ nonce }
@@ -305,18 +340,80 @@ class StatelessTransaction extends React.Component {
305 </InnerLabel>
340 </InnerLabel>
343+ const chainDialogueTitle = customChain ? "Custom" : chainId
308 const chainDialogue =
344 const chainDialogue =
309− <Input
345+ <InnerLabelDropdown
310− className={ 'mono mt-4 mb-8' }
346+ className={'mt-6'}
311− prop-size={ 'md' }
347+ handleToggle={this.toggleChainDropdown}
312− prop-format={ 'innerLabel' }
348+ handleClose={this.closeChainDropdown}
313− value={ chainId }
349+ fullWidth={true}
314− onChange={ setChainId }
350+ isOpen={chainDropdownOpen}
352+ currentSelectionTitle={chainDialogueTitle}
355+ isSelected={ false }
356+ onClick={() => selectChain("1")}
363+ onClick={() => selectChain("2")}
370+ onClick={() => selectChain("3")}
377+ onClick={() => selectChain("4")}
384+ onClick={() => selectChain("42")}
391+ onClick={() => selectChain("1337")}
393+ {'1337 - Geth private chains'}
398+ onClick={this.openCustomChain}
403+ </InnerLabelDropdown>
405+ const customChainDialogue = !customChain ? null :
407+ className={ 'mono mt-4 mb-8' }
409+ prop-format={ 'innerLabel' }
411+ onChange={ setChainId }
316− <InnerLabel>
413+ <InnerLabel>
317− { 'Chain ID' }
414+ { 'Chain ID' }
318− </InnerLabel>
415+ </InnerLabel>
319− </Input>
416+ </Input>
321 const onlineParamsDialogue = web3.matchWith({
418 const onlineParamsDialogue = web3.matchWith({
322 Just: _ => <div />,
419 Just: _ => <div />,
@@ -324,6 +421,7 @@ class StatelessTransaction extends React.Component {
324 <React.Fragment>
421 <React.Fragment>
325 { nonceDialogue }
422 { nonceDialogue }
326 { chainDialogue }
423 { chainDialogue }
424+ { customChainDialogue }
327 </React.Fragment>
425 </React.Fragment>