@@ -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'
@@ -27,11 +28,12 @@ class StatelessTransaction extends React.Component {
27 gasLimit: '600000',
28 gasLimit: '600000',
28 showGasDetails: false,
29 showGasDetails: false,
29 userApproval: false,
30 userApproval: false,
30− chainId: '',
31+ chainId: '1',
31− nonce: '',
33+ nonce: '0',
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() {
@@ -85,17 +88,20 @@ class StatelessTransaction extends React.Component {
87 const { props, state } = this
90 const { props, state } = this
88− sendSignedTransaction(props.web3.value, state.stx)
91+ sendSignedTransaction(props.web3.value, state.stx, props.setTxnConfirmations)
89 .then(sent => {
92 .then(sent => {
90 props.setTxnHashCursor(sent)
93 props.setTxnHashCursor(sent)
91 props.popRoute()
94 props.popRoute()
93 if (props.networkSeed) {
97 if (props.networkSeed) {
94− props.setNetworkSeedCache(props.networkSeed)
98+ props.setNetworkSeedCache(props.networkSeed);
95− props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION, {promptKeyfile: true})
99+ routeData.promptKeyfile = true;
97− props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
101+ if (props.promptText) {
102+ routeData.promptText = props.promptText;
104+ props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION, routeData);
100 .catch(err => {
106 .catch(err => {
101 if (err.map) {
107 if (err.map) {
@@ -106,6 +112,21 @@ class StatelessTransaction extends React.Component {
115+ handleChainUpdate(chainId) {
116+ if (chainId === "custom") {
109 setUserApproval(){
130 setUserApproval(){
110 const {state} = this
131 const {state} = this
111 this.setState({ userApproval: !state.userApproval })
132 this.setState({ userApproval: !state.userApproval })
@@ -185,13 +206,53 @@ class StatelessTransaction extends React.Component {
185 this.submit()
206 this.submit()
209+ getChainTitle(chainId) {
216+ "1337": "Geth private chains - 1337",
225+ title: this.getChainTitle("1"),
228+ title: this.getChainTitle("2"),
231+ title: this.getChainTitle("3"),
234+ title: this.getChainTitle("4"),
237+ title: this.getChainTitle("42"),
240+ title: this.getChainTitle("1337"),
243+ title: this.getChainTitle("custom"),
188 render() {
248 render() {
189 const { web3, canGenerate } = this.props
249 const { web3, canGenerate } = this.props
190 const { gasPrice, gasLimit, nonce, chainId,
250 const { gasPrice, gasLimit, nonce, chainId,
191− txn, stx, userApproval, showGasDetails } = this.state
251+ txn, stx, userApproval, showGasDetails,
252+ customChain } = this.state
193 const { setNonce, setChainId, setGasLimit, setGasPrice, toggleGasDetails,
254 const { setNonce, setChainId, setGasLimit, setGasPrice, toggleGasDetails,
194− setUserApproval, sendTxn, createUnsignedTxn } = this
255+ setUserApproval, sendTxn, createUnsignedTxn, handleChainUpdate } = this
196 const { state } = this
257 const { state } = this
@@ -199,6 +260,8 @@ class StatelessTransaction extends React.Component {
199 const canApprove = Just.hasInstance(stx)
260 const canApprove = Just.hasInstance(stx)
200 const canSend = Just.hasInstance(stx) && userApproval === true
261 const canSend = Just.hasInstance(stx) && userApproval === true
263+ const chainOptions = this.getChainOptions()
202 const generateButtonColor =
265 const generateButtonColor =
203 Nothing.hasInstance(txn)
266 Nothing.hasInstance(txn)
@@ -294,7 +357,7 @@ class StatelessTransaction extends React.Component {
295 const nonceDialogue =
358 const nonceDialogue =
297− className={ 'mono mt-4' }
360+ className={ 'mono mt-4 mb-4' }
298 prop-size={ 'md' }
361 prop-size={ 'md' }
299 prop-format={ 'innerLabel' }
362 prop-format={ 'innerLabel' }
300 value={ nonce }
363 value={ nonce }
@@ -305,18 +368,30 @@ class StatelessTransaction extends React.Component {
305 </InnerLabel>
368 </InnerLabel>
371+ const chainDialogueTitle = customChain ? "Custom" : this.getChainTitle(chainId)
308 const chainDialogue =
372 const chainDialogue =
309− <Input
373+ <InnerLabelDropdown
310− className={ 'mono mt-4 mb-8' }
374+ className={'mt-6'}
311− prop-size={ 'md' }
375+ fullWidth={true}
312− prop-format={ 'innerLabel' }
376+ title={'Chain ID'}
313− value={ chainId }
377+ options={chainOptions}
314− onChange={ setChainId }
378+ handleUpdate={handleChainUpdate}
379+ currentSelectionTitle={chainDialogueTitle}
381+ </InnerLabelDropdown>
383+ const customChainDialogue = !customChain ? null :
385+ className={ 'mono mt-4 mb-8' }
387+ prop-format={ 'innerLabel' }
389+ onChange={ setChainId }
316− <InnerLabel>
391+ <InnerLabel>
317− { 'Chain ID' }
392+ { 'Chain ID' }
318− </InnerLabel>
393+ </InnerLabel>
319− </Input>
394+ </Input>
321 const onlineParamsDialogue = web3.matchWith({
396 const onlineParamsDialogue = web3.matchWith({
322 Just: _ => <div />,
397 Just: _ => <div />,
@@ -324,6 +399,7 @@ class StatelessTransaction extends React.Component {
324 <React.Fragment>
399 <React.Fragment>
325 { nonceDialogue }
400 { nonceDialogue }
326 { chainDialogue }
401 { chainDialogue }
402+ { customChainDialogue }
327 </React.Fragment>
403 </React.Fragment>
@@ -358,7 +434,7 @@ class StatelessTransaction extends React.Component {
358 onClick={ setUserApproval }
434 onClick={ setUserApproval }
359 state={ userApproval }
435 state={ userApproval }
361− <div>
437+ <div onClick={ setUserApproval }>
362 { `I approve this transaction and wish to send.` }
438 { `I approve this transaction and wish to send.` }
364 </CheckboxButton>
440 </CheckboxButton>