@@ -3,37 +3,40 @@ import React from 'react'
33
44import { Code, H3 } from './Base'
55import { Button } from './Base'
6−import { CheckboxButton, Input, InnerLabel } from './Base'
6+import { CheckboxButton, Input, InnerLabel } from './Base'
77
8−import {
9− renderSignedTx,
10− signTransaction,
11− } from '../lib/txn'
8+import { renderSignedTx, signTransaction } from '../lib/txn'
129
1310const StatelessTransaction = props => {
11+ const { web3, gasPrice, gasLimit, nonce, chainId } = props
12+ const { setNonce, setChainId, setGasLimit, setGasPrice } = props
13+ const { txn, stx, createUnsignedTxn } = props
14+ const { canSign, canGenerate, canApprove } = props
15+ const { setUserApproval, userApproval } = props
16+ const { canSend, handleSubmit } = props
1417
1518 const generateButtonColor =
16− Nothing.hasInstance(props.txn)
19+ Nothing.hasInstance(txn)
1720 ? 'blue'
1821 : 'green'
1922
2023 const signerButtonColor =
21− Nothing.hasInstance(props.stx)
24+ Nothing.hasInstance(stx)
2225 ? 'blue'
2326 : 'green'
2427
2528 const generateTxnButton =
2629 <Button
2730 className={ 'mt-8' }
28− disabled={ !props.canGenerate }
31+ disabled={ !canGenerate }
2932 prop-color={ generateButtonColor }
3033 prop-size={ 'lg wide' }
31− onClick={ () => props.createUnsignedTxn() }
34+ onClick={ createUnsignedTxn }
3235 >
3336 { 'Generate Transaction' }
3437 </Button>
3538
36− const unsignedTxnDisplay = props.txn.matchWith({
39+ const unsignedTxnDisplay = txn.matchWith({
3740 Nothing: _ => '',
3841 Just: tx =>
3942 <React.Fragment>
@@ -51,8 +54,8 @@ const StatelessTransaction = props => {
5154 className={ 'mono mt-4' }
5255 prop-size={ 'md' }
5356 prop-format={ 'innerLabel' }
54− value={ props.gasPrice }
55− onChange={ props.setGasPrice }
57+ value={ gasPrice }
58+ onChange={ setGasPrice }
5659 >
5760 <InnerLabel>
5861 { 'Gas Price (gwei)' }
@@ -64,8 +67,8 @@ const StatelessTransaction = props => {
6467 className={ 'mono mt-4' }
6568 prop-size={ 'md' }
6669 prop-format={ 'innerLabel' }
67− value={ props.gasLimit }
68− onChange={ props.setGasLimit }>
70+ value={ gasLimit }
71+ onChange={ setGasLimit }>
6972 <InnerLabel>
7073 { 'Gas Limit' }
7174 </InnerLabel>
@@ -76,8 +79,8 @@ const StatelessTransaction = props => {
7679 className={ 'mono mt-4' }
7780 prop-size={ 'md' }
7881 prop-format={ 'innerLabel' }
79− value={ props.nonce }
80− onChange={ props.setNonce }
82+ value={ nonce }
83+ onChange={ setNonce }
8184 >
8285 <InnerLabel>
8386 { 'Nonce' }
@@ -89,15 +92,15 @@ const StatelessTransaction = props => {
8992 className={ 'mono mt-4 mb-8' }
9093 prop-size={ 'md' }
9194 prop-format={ 'innerLabel' }
92− value={ props.chainId }
93− onChange={ props.setChainId }
95+ value={ chainId }
96+ onChange={ setChainId }
9497 >
9598 <InnerLabel>
9699 { 'Chain ID' }
97100 </InnerLabel>
98101 </Input>
99102
100− const onlineParamsDialogue = props.web3.matchWith({
103+ const onlineParamsDialogue = web3.matchWith({
101104 Just: _ => <div />,
102105 Nothing: _ =>
103106 <React.Fragment>
@@ -108,7 +111,7 @@ const StatelessTransaction = props => {
108111
109112 const signTxnButton =
110113 <Button
111− disabled={ !props.canSign }
114+ disabled={ !canSign }
112115 className={ 'mt-8' }
113116 prop-size={ 'lg wide' }
114117 prop-color={ signerButtonColor }
@@ -117,7 +120,7 @@ const StatelessTransaction = props => {
117120 { 'Sign Transaction' }
118121 </Button>
119122
120− const signedTxnDisplay = props.stx.matchWith({
123+ const signedTxnDisplay = stx.matchWith({
121124 Nothing: _ => '',
122125 Just: tx =>
123126 <React.Fragment>
@@ -133,9 +136,9 @@ const StatelessTransaction = props => {
133136 const confirmButton =
134137 <CheckboxButton
135138 className={ 'mt-8' }
136− disabled={ !props.canApprove }
137− onClick={ props.setUserApproval }
138− state={ props.userApproval }
139+ disabled={ !canApprove }
140+ onClick={ setUserApproval }
141+ state={ userApproval }
139142 >
140143 <div>
141144 { `I approve this transaction and wish to send.` }
@@ -146,13 +149,13 @@ const StatelessTransaction = props => {
146149 <Button
147150 prop-size={ 'xl wide' }
148151 className={ 'mt-8' }
149− disabled={ !props.canSend }
150− onClick={ props.handleSubmit }
152+ disabled={ !canSend }
153+ onClick={ handleSubmit }
151154 >
152155 { 'Send Transaction' }
153156 </Button>
154157
155− const sendDialogue = props.web3.matchWith({
158+ const sendDialogue = web3.matchWith({
156159 Nothing: _ => '',
157160 Just: _ =>
158161 <React.Fragment>
@@ -162,22 +165,20 @@ const StatelessTransaction = props => {
162165 })
163166
164167 return (
165− <React.Fragment>
166− { generateTxnButton }
167− { unsignedTxnDisplay }
168+ <React.Fragment>
169+ { generateTxnButton }
170+ { unsignedTxnDisplay }
168171
169− { gasPriceDialogue }
170− { gasLimitDialogue }
171− { onlineParamsDialogue }
172+ { gasPriceDialogue }
173+ { gasLimitDialogue }
174+ { onlineParamsDialogue }
172175
173− { signTxnButton }
176+ { signTxnButton }
174177
175− { signedTxnDisplay }
176− { sendDialogue }
178+ { signedTxnDisplay }
179+ { sendDialogue }
177180 </React.Fragment>
178181 )
179182}
180183
181−
182−
183184export default StatelessTransaction