@@ -3,37 +3,40 @@ 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 } from './Base'
10− signTransaction,
8+import { renderSignedTx, signTransaction } from '../lib/txn'
13const StatelessTransaction = props => {
10const 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
15 const generateButtonColor =
18 const generateButtonColor =
16− Nothing.hasInstance(props.txn)
19+ Nothing.hasInstance(txn)
20 const signerButtonColor =
23 const signerButtonColor =
21− Nothing.hasInstance(props.stx)
24+ Nothing.hasInstance(stx)
25 const generateTxnButton =
28 const generateTxnButton =
27 className={ 'mt-8' }
30 className={ 'mt-8' }
28− disabled={ !props.canGenerate }
31+ disabled={ !canGenerate }
29 prop-color={ generateButtonColor }
32 prop-color={ generateButtonColor }
30 prop-size={ 'lg wide' }
33 prop-size={ 'lg wide' }
31− onClick={ () => props.createUnsignedTxn() }
34+ onClick={ createUnsignedTxn }
33 { 'Generate Transaction' }
36 { 'Generate Transaction' }
36− const unsignedTxnDisplay = props.txn.matchWith({
39+ const unsignedTxnDisplay = txn.matchWith({
37 Nothing: _ => '',
40 Nothing: _ => '',
38 Just: tx =>
41 Just: tx =>
39 <React.Fragment>
42 <React.Fragment>
@@ -51,8 +54,8 @@ const StatelessTransaction = props => {
51 className={ 'mono mt-4' }
54 className={ 'mono mt-4' }
52 prop-size={ 'md' }
55 prop-size={ 'md' }
53 prop-format={ 'innerLabel' }
56 prop-format={ 'innerLabel' }
54− value={ props.gasPrice }
57+ value={ gasPrice }
55− onChange={ props.setGasPrice }
58+ onChange={ setGasPrice }
57 <InnerLabel>
60 <InnerLabel>
58 { 'Gas Price (gwei)' }
61 { 'Gas Price (gwei)' }
@@ -64,8 +67,8 @@ const StatelessTransaction = props => {
64 className={ 'mono mt-4' }
67 className={ 'mono mt-4' }
65 prop-size={ 'md' }
68 prop-size={ 'md' }
66 prop-format={ 'innerLabel' }
69 prop-format={ 'innerLabel' }
67− value={ props.gasLimit }
70+ value={ gasLimit }
68− onChange={ props.setGasLimit }>
71+ onChange={ setGasLimit }>
69 <InnerLabel>
72 <InnerLabel>
70 { 'Gas Limit' }
73 { 'Gas Limit' }
71 </InnerLabel>
74 </InnerLabel>
@@ -76,8 +79,8 @@ const StatelessTransaction = props => {
76 className={ 'mono mt-4' }
79 className={ 'mono mt-4' }
77 prop-size={ 'md' }
80 prop-size={ 'md' }
78 prop-format={ 'innerLabel' }
81 prop-format={ 'innerLabel' }
79− value={ props.nonce }
82+ value={ nonce }
80− onChange={ props.setNonce }
83+ onChange={ setNonce }
82 <InnerLabel>
85 <InnerLabel>
83 { 'Nonce' }
86 { 'Nonce' }
@@ -89,15 +92,15 @@ const StatelessTransaction = props => {
89 className={ 'mono mt-4 mb-8' }
92 className={ 'mono mt-4 mb-8' }
90 prop-size={ 'md' }
93 prop-size={ 'md' }
91 prop-format={ 'innerLabel' }
94 prop-format={ 'innerLabel' }
92− value={ props.chainId }
95+ value={ chainId }
93− onChange={ props.setChainId }
96+ onChange={ setChainId }
95 <InnerLabel>
98 <InnerLabel>
96 { 'Chain ID' }
99 { 'Chain ID' }
97 </InnerLabel>
100 </InnerLabel>
100− const onlineParamsDialogue = props.web3.matchWith({
103+ const onlineParamsDialogue = web3.matchWith({
101 Just: _ => <div />,
104 Just: _ => <div />,
102 Nothing: _ =>
105 Nothing: _ =>
103 <React.Fragment>
106 <React.Fragment>
@@ -108,7 +111,7 @@ const StatelessTransaction = props => {
109 const signTxnButton =
112 const signTxnButton =
111− disabled={ !props.canSign }
114+ disabled={ !canSign }
112 className={ 'mt-8' }
115 className={ 'mt-8' }
113 prop-size={ 'lg wide' }
116 prop-size={ 'lg wide' }
114 prop-color={ signerButtonColor }
117 prop-color={ signerButtonColor }
@@ -117,7 +120,7 @@ const StatelessTransaction = props => {
117 { 'Sign Transaction' }
120 { 'Sign Transaction' }
118 </Button>
121 </Button>
120− const signedTxnDisplay = props.stx.matchWith({
123+ const signedTxnDisplay = stx.matchWith({
121 Nothing: _ => '',
124 Nothing: _ => '',
122 Just: tx =>
125 Just: tx =>
123 <React.Fragment>
126 <React.Fragment>
@@ -133,9 +136,9 @@ const StatelessTransaction = props => {
133 const confirmButton =
136 const confirmButton =
134 <CheckboxButton
137 <CheckboxButton
135 className={ 'mt-8' }
138 className={ 'mt-8' }
136− disabled={ !props.canApprove }
139+ disabled={ !canApprove }
137− onClick={ props.setUserApproval }
140+ onClick={ setUserApproval }
138− state={ props.userApproval }
141+ state={ userApproval }
141 { `I approve this transaction and wish to send.` }
144 { `I approve this transaction and wish to send.` }
@@ -146,13 +149,13 @@ const StatelessTransaction = props => {
147 prop-size={ 'xl wide' }
150 prop-size={ 'xl wide' }
148 className={ 'mt-8' }
151 className={ 'mt-8' }
149− disabled={ !props.canSend }
152+ disabled={ !canSend }
150− onClick={ props.handleSubmit }
153+ onClick={ handleSubmit }
152 { 'Send Transaction' }
155 { 'Send Transaction' }
153 </Button>
156 </Button>
155− const sendDialogue = props.web3.matchWith({
158+ const sendDialogue = web3.matchWith({
156 Nothing: _ => '',
159 Nothing: _ => '',
157 Just: _ =>
160 Just: _ =>
158 <React.Fragment>
161 <React.Fragment>
@@ -162,22 +165,20 @@ const StatelessTransaction = props => {
165− <React.Fragment>
168+ <React.Fragment>
166− { generateTxnButton }
169+ { generateTxnButton }
167− { unsignedTxnDisplay }
170+ { unsignedTxnDisplay }
169− { gasPriceDialogue }
172+ { gasPriceDialogue }
170− { gasLimitDialogue }
173+ { gasLimitDialogue }
171− { onlineParamsDialogue }
174+ { onlineParamsDialogue }
173− { signTxnButton }
176+ { signTxnButton }
175− { signedTxnDisplay }
178+ { signedTxnDisplay }
176− { sendDialogue }
179+ { sendDialogue }
177 </React.Fragment>
180 </React.Fragment>
183export default StatelessTransaction
184export default StatelessTransaction