@@ -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 } 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,11 @@ class StatelessTransaction extends React.Component {
28 showGasDetails: false,
29 showGasDetails: false,
29 userApproval: false,
30 userApproval: false,
30 chainId: '',
31 chainId: '',
31 nonce: '',
33 nonce: '',
32 stx: Nothing(),
34 stx: Nothing(),
33 txn: Nothing(),
35 txn: Nothing(),
34− txError: Nothing(),
36+ txError: Nothing()
37 this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
39 this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
@@ -46,6 +48,7 @@ class StatelessTransaction extends React.Component {
46 this.setGasLimit = this.setGasLimit.bind(this)
48 this.setGasLimit = this.setGasLimit.bind(this)
47 this.rangeChange = this.rangeChange.bind(this)
49 this.rangeChange = this.rangeChange.bind(this)
48 this.toggleGasDetails = this.toggleGasDetails.bind(this)
50 this.toggleGasDetails = this.toggleGasDetails.bind(this)
51+ this.handleChainUpdate = this.handleChainUpdate.bind(this)
51 componentDidMount() {
54 componentDidMount() {
@@ -106,6 +109,19 @@ class StatelessTransaction extends React.Component {
112+ handleChainUpdate(chainId) {
113+ if (chainId === "custom") {
109 setUserApproval(){
125 setUserApproval(){
110 const {state} = this
126 const {state} = this
111 this.setState({ userApproval: !state.userApproval })
127 this.setState({ userApproval: !state.userApproval })
@@ -185,13 +201,53 @@ class StatelessTransaction extends React.Component {
185 this.submit()
201 this.submit()
204+ getChainTitle(chainId) {
211+ "1337": "Geth private chains - 1337",
220+ title: this.getChainTitle("1"),
223+ title: this.getChainTitle("2"),
226+ title: this.getChainTitle("3"),
229+ title: this.getChainTitle("4"),
232+ title: this.getChainTitle("42"),
235+ title: this.getChainTitle("1337"),
238+ title: this.getChainTitle("custom"),
188 render() {
243 render() {
189 const { web3, canGenerate } = this.props
244 const { web3, canGenerate } = this.props
190 const { gasPrice, gasLimit, nonce, chainId,
245 const { gasPrice, gasLimit, nonce, chainId,
191− txn, stx, userApproval, showGasDetails } = this.state
246+ txn, stx, userApproval, showGasDetails,
247+ customChain } = this.state
193 const { setNonce, setChainId, setGasLimit, setGasPrice, toggleGasDetails,
249 const { setNonce, setChainId, setGasLimit, setGasPrice, toggleGasDetails,
194− setUserApproval, sendTxn, createUnsignedTxn } = this
250+ setUserApproval, sendTxn, createUnsignedTxn, handleChainUpdate } = this
196 const { state } = this
252 const { state } = this
@@ -199,6 +255,8 @@ class StatelessTransaction extends React.Component {
199 const canApprove = Just.hasInstance(stx)
255 const canApprove = Just.hasInstance(stx)
200 const canSend = Just.hasInstance(stx) && userApproval === true
256 const canSend = Just.hasInstance(stx) && userApproval === true
258+ const chainOptions = this.getChainOptions()
202 const generateButtonColor =
260 const generateButtonColor =
203 Nothing.hasInstance(txn)
261 Nothing.hasInstance(txn)
@@ -294,7 +352,7 @@ class StatelessTransaction extends React.Component {
295 const nonceDialogue =
353 const nonceDialogue =
297− className={ 'mono mt-4' }
355+ className={ 'mono mt-4 mb-4' }
298 prop-size={ 'md' }
356 prop-size={ 'md' }
299 prop-format={ 'innerLabel' }
357 prop-format={ 'innerLabel' }
300 value={ nonce }
358 value={ nonce }
@@ -305,18 +363,30 @@ class StatelessTransaction extends React.Component {
305 </InnerLabel>
363 </InnerLabel>
366+ const chainDialogueTitle = customChain ? "Custom" : this.getChainTitle(chainId)
308 const chainDialogue =
367 const chainDialogue =
309− <Input
368+ <InnerLabelDropdown
310− className={ 'mono mt-4 mb-8' }
369+ className={'mt-6'}
311− prop-size={ 'md' }
370+ fullWidth={true}
312− prop-format={ 'innerLabel' }
371+ title={'Chain ID'}
313− value={ chainId }
372+ options={chainOptions}
314− onChange={ setChainId }
373+ handleUpdate={handleChainUpdate}
374+ currentSelectionTitle={chainDialogueTitle}
376+ </InnerLabelDropdown>
378+ const customChainDialogue = !customChain ? null :
380+ className={ 'mono mt-4 mb-8' }
382+ prop-format={ 'innerLabel' }
384+ onChange={ setChainId }
316− <InnerLabel>
386+ <InnerLabel>
317− { 'Chain ID' }
387+ { 'Chain ID' }
318− </InnerLabel>
388+ </InnerLabel>
319− </Input>
389+ </Input>
321 const onlineParamsDialogue = web3.matchWith({
391 const onlineParamsDialogue = web3.matchWith({
322 Just: _ => <div />,
392 Just: _ => <div />,
@@ -324,6 +394,7 @@ class StatelessTransaction extends React.Component {
324 <React.Fragment>
394 <React.Fragment>
325 { nonceDialogue }
395 { nonceDialogue }
326 { chainDialogue }
396 { chainDialogue }
397+ { customChainDialogue }
327 </React.Fragment>
398 </React.Fragment>