@@ -43,100 +43,35 @@ class IssueChild extends React.Component {
45 this.state = {
45 this.state = {
47 receivingAddress: '',
46 receivingAddress: '',
48 issuingPoint: issuingPoint,
47 issuingPoint: issuingPoint,
49 desiredPoint: '',
48 desiredPoint: '',
50 isAvailable: Nothing(), // use Nothing to allow attempt when offline
49 isAvailable: Nothing(), // use Nothing to allow attempt when offline
54− showGasDetails: false,
59 suggestions: suggestions,
50 suggestions: suggestions,
62 this.handlePointInput = this.handlePointInput.bind(this)
53 this.handlePointInput = this.handlePointInput.bind(this)
63 this.handleAddressInput = this.handleAddressInput.bind(this)
54 this.handleAddressInput = this.handleAddressInput.bind(this)
64 this.handleConfirmAvailability = this.handleConfirmAvailability.bind(this)
55 this.handleConfirmAvailability = this.handleConfirmAvailability.bind(this)
65− this.handleCreateUnsignedTxn = this.handleCreateUnsignedTxn.bind(this)
56+ this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
66− this.handleSubmit = this.handleSubmit.bind(this)
57+ this.statelessRef = React.createRef();
67− this.handleSetUserApproval = this.handleSetUserApproval.bind(this)
68− this.handleSetTxn = this.handleSetTxn.bind(this)
69− this.handleSetStx = this.handleSetStx.bind(this)
70− this.handleSetNonce = this.handleSetNonce.bind(this)
71− this.handleSetChainId = this.handleSetChainId.bind(this)
72− this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
73− this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
74− this.toggleGasDetails = this.toggleGasDetails.bind(this)
79− showGasDetails: !this.state.showGasDetails
83− componentDidMount() {
84− const { props } = this
86− const addr = props.wallet.matchWith({
87− Just: wal => addressFromSecp256k1Public(wal.value.publicKey),
89− throw BRIDGE_ERROR.MISSING_WALLET
93− props.web3.matchWith({
96− const validWeb3 = w3.value
98− const getTxMetadata = [
99− validWeb3.eth.getTransactionCount(addr),
100− validWeb3.eth.net.getId(),
101− validWeb3.eth.getGasPrice()
104− Promise.all(getTxMetadata).then(r => {
105− const txMetadata = {
108− gasPrice: fromWei(r[2], 'gwei'),
111− this.setState({...txMetadata})
121 handleAddressInput = (receivingAddress) => {
60 handleAddressInput = (receivingAddress) => {
122 this.setState({ receivingAddress })
61 this.setState({ receivingAddress })
123− this.handleClearTxn()
62+ this.statelessRef.current.clearTxn()
128 handlePointInput(desiredPoint) {
65 handlePointInput(desiredPoint) {
129 if (desiredPoint.length < 15) {
66 if (desiredPoint.length < 15) {
130 this.setState({
67 this.setState({
131 desiredPoint,
68 desiredPoint,
132 isAvailable: Nothing()
69 isAvailable: Nothing()
134− this.handleClearTxn()
71+ this.statelessRef.current.clearTxn()
140 handleConfirmAvailability() {
75 handleConfirmAvailability() {
141 this.confirmPointAvailability().then(r => {
76 this.confirmPointAvailability().then(r => {
142 this.setState({
77 this.setState({
@@ -146,106 +81,6 @@ class IssueChild extends React.Component {
151− handleCreateUnsignedTxn() {
152− const txn = this.createUnsignedTxn()
153− this.setState({ txn })
157− handleSetUserApproval(){
158− const {state} = this
159− this.setState({ userApproval: !state.userApproval })
165− this.setState({ txn })
173− userApproval: false,
179− handleSetNonce(nonce){
180− this.setState({ nonce })
181− this.handleClearStx()
186− handleSetChainId(chainId){
187− this.setState({ chainId })
188− this.handleClearStx()
193− handleSetGasPrice(gasPrice){
194− this.setState({ gasPrice })
195− this.handleClearStx()
200− handleSetGasLimit(gasLimit){
201− this.setState({ gasLimit })
202− this.handleClearStx()
209− userApproval: false,
218− userApproval: false,
226− handleClearTransaction() {
228− userApproval: false,
237− const { props, state } = this
238− sendSignedTransaction(props.web3.value, state.stx)
240− props.setTxnHashCursor(sent)
242− props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
245− this.setState({ txError: err.map(val => val.merge()) })
249 async confirmPointAvailability() {
84 async confirmPointAvailability() {
250 const { contracts } = this.props
85 const { contracts } = this.props
251 const { desiredPoint } = this.state
86 const { desiredPoint } = this.state
@@ -307,8 +142,6 @@ class IssueChild extends React.Component {
307 return Just(txn)
142 return Just(txn)
312 buttonTriState() {
145 buttonTriState() {
313 const a = this.state.isAvailable
146 const a = this.state.isAvailable
314 if (Nothing.hasInstance(a)) return 'blue'
147 if (Nothing.hasInstance(a)) return 'blue'
@@ -316,8 +149,6 @@ class IssueChild extends React.Component {
316 if (a.value === true) return 'green'
149 if (a.value === true) return 'green'
321 buttonTriStateText() {
152 buttonTriStateText() {
322 const a = this.state.isAvailable
153 const a = this.state.isAvailable
323 if (Nothing.hasInstance(a)) return 'Confirm Availablility'
154 if (Nothing.hasInstance(a)) return 'Confirm Availablility'
@@ -343,7 +174,6 @@ class IssueChild extends React.Component {
343 return vpatp && vchild
174 return vpatp && vchild
347 render() {
177 render() {
348 const { props, state } = this
178 const { props, state } = this
@@ -362,12 +192,6 @@ class IssueChild extends React.Component {
365− const canSign = Just.hasInstance(state.txn)
366− const canApprove = Just.hasInstance(state.stx)
368− Just.hasInstance(state.stx)
369− && state.userApproval === true
371 const esvisible =
195 const esvisible =
372 props.networkType === NETWORK_NAMES.ROPSTEN ||
196 props.networkType === NETWORK_NAMES.ROPSTEN ||
373 props.networkType === NETWORK_NAMES.MAINNET
197 props.networkType === NETWORK_NAMES.MAINNET
@@ -480,46 +304,13 @@ class IssueChild extends React.Component {
480 walletType={props.walletType}
304 walletType={props.walletType}
481 walletHdPath={props.walletHdPath}
305 walletHdPath={props.walletHdPath}
482 networkType={props.networkType}
306 networkType={props.networkType}
483− // Tx
307+ setTxnHashCursor={props.setTxnHashCursor}
484− txn={state.txn}
308+ popRoute={props.popRoute}
485− stx={state.stx}
309+ pushRoute={props.pushRoute}
486− // Tx details
310+ // Other
488− gasPrice={state.gasPrice}
489− showGasDetails={state.showGasDetails}
490− toggleGasDetails={this.toggleGasDetails}
491− chainId={state.chainId}
492− gasLimit={state.gasLimit}
494− userApproval={state.userApproval}
495− canGenerate={ canGenerate }
311+ canGenerate={canGenerate}
497− canApprove={ canApprove }
500− createUnsignedTxn={this.handleCreateUnsignedTxn}
312+ createUnsignedTxn={this.createUnsignedTxn}
501− setUserApproval={this.handleSetUserApproval}
313+ ref={this.statelessRef} />
502− setTxn={this.handleSetTxn}
503− setStx={this.handleSetStx}
504− setNonce={this.handleSetNonce}
505− setChainId={this.handleSetChainId}
506− setGasPrice={this.handleSetGasPrice}
507− setGasLimit={this.handleSetGasLimit}
508− handleSubmit={this.handleSubmit} />
511− Nothing.hasInstance(state.txError)
513− : <Warning className={'mt-8'}>
514− <H3 style={{marginTop: 0, paddingTop: 0}}>
516− 'There was an error sending your transaction.'
519− { state.txError.value }