@@ -1,4 +1,4 @@
1−import Maybe from 'folktale/maybe'
1+import { Nothing } from 'folktale/maybe'
2import React from 'react'
2import React from 'react'
4import { Code, H3 } from './Base'
4import { Code, H3 } from './Base'
@@ -7,167 +7,173 @@ import { CheckboxButton, Input, InnerLabel } from './Base'
9 renderSignedTx,
9 renderSignedTx,
10− // createUnsignedTxn,
11 signTransaction,
10 signTransaction,
12−} from '../lib/txn';
11+ } from '../lib/txn'
16const StatelessTransaction = props => {
13const StatelessTransaction = props => {
15+ const generateButtonColor =
18− const generateButtonColor = Maybe.Nothing.hasInstance(props.txn)
16+ Nothing.hasInstance(props.txn)
20+ const signerButtonColor =
22− const signerButtonColor = Maybe.Nothing.hasInstance(props.stx)
21+ Nothing.hasInstance(props.stx)
25+ const generateTxnButton =
28+ disabled={ !props.canGenerate }
29+ prop-color={ generateButtonColor }
30+ prop-size={ 'lg wide' }
31+ onClick={ () => props.createUnsignedTxn() }
33+ { 'Generate Transaction' }
36+ const unsignedTxnDisplay = props.txn.matchWith({
40+ <H3 className={ 'mt-8' }>
41+ { 'Unsigned Transaction' }
44+ { JSON.stringify(tx.value, null, 2) }
49+ const gasPriceDialogue =
51+ className={ 'mono mt-4' }
53+ prop-format={ 'innerLabel' }
54+ value={ props.gasPrice }
55+ onChange={ props.setGasPrice }
58+ { 'Gas Price (gwei)' }
62+ const gasLimitDialogue =
64+ className={ 'mono mt-4' }
66+ prop-format={ 'innerLabel' }
67+ value={ props.gasLimit }
68+ onChange={ props.setGasLimit }>
74+ const nonceDialogue =
76+ className={ 'mono mt-4' }
78+ prop-format={ 'innerLabel' }
79+ value={ props.nonce }
80+ onChange={ props.setNonce }
87+ const chainDialogue =
89+ className={ 'mono mt-4 mb-8' }
91+ prop-format={ 'innerLabel' }
92+ value={ props.chainId }
93+ onChange={ props.setChainId }
100+ const onlineParamsDialogue = props.web3.matchWith({
109+ const signTxnButton =
111+ disabled={ !props.canSign }
112+ className={ 'mt-8' }
113+ prop-size={ 'lg wide' }
114+ prop-color={ signerButtonColor }
115+ onClick={ () => signTransaction(props) }
117+ { 'Sign Transaction' }
120+ const signedTxnDisplay = props.stx.matchWith({
124+ <H3 className={ 'mt-8' }>
125+ { 'Signed Transaction' }
128+ { JSON.stringify(renderSignedTx(tx.value), null, 2) }
133+ const confirmButton =
135+ className={ 'mt-8' }
136+ disabled={ !props.canApprove }
137+ onClick={ props.setUserApproval }
138+ state={ props.userApproval }
141+ { `I approve this transaction and wish to send.` }
145+ const sendTxnButton =
147+ prop-size={ 'xl wide' }
148+ className={ 'mt-8' }
149+ disabled={ !props.canSend }
150+ onClick={ props.handleSubmit }
152+ { 'Send Transaction' }
155+ const sendDialogue = props.web3.matchWith({
27 <React.Fragment>
165 <React.Fragment>
166+ { generateTxnButton }
167+ { unsignedTxnDisplay }
169+ { gasPriceDialogue }
170+ { gasLimitDialogue }
171+ { onlineParamsDialogue }
29− <Button
175+ { signedTxnDisplay }
30− prop-size={'lg wide'}
176+ { sendDialogue }
31− prop-color={generateButtonColor}
33− disabled={ !props.canGenerate }
34− onClick={ () => props.createUnsignedTxn()}>
35− { 'Generate Transaction' }
40− props.txn.matchWith({
43− console.log(tx.value)
44− const rendered = tx.value
47− <H3 className={'mt-8'}>{'Unsigned Transaction'}</H3>
48− <Code> {JSON.stringify(rendered, null, 2)} </Code>
57− className='mono mt-4'
59− prop-format='innerLabel'
60− value={ props.gasPrice }
61− onChange={ v => props.setGasPrice(v) }>
63− { 'Gas Price (gwei)' }
68− className='mono mt-4'
70− prop-format='innerLabel'
71− value={ props.gasLimit }
72− onChange={ v => props.setGasLimit(v) }>
79− props.web3.matchWith({
84− className='mono mt-4'
86− prop-format='innerLabel'
87− value={ props.nonce }
88− onChange={ v => props.setNonce(v) }>
95− className='mono mt-4 mb-8'
97− prop-format='innerLabel'
98− value={ props.chainId }
99− onChange={ v => props.setChainId(v) }>
109− disabled={ !props.canSign }
111− prop-size={'lg wide'}
112− prop-color={signerButtonColor}
113− onClick={ () => signTransaction({
114− wallet: props.wallet,
115− walletType: props.walletType,
116− walletHdPath: props.walletHdPath,
117− networkType: props.networkType,
119− setStx: props.setStx,
121− chainId: props.chainId,
122− gasPrice: props.gasPrice,
123− gasLimit: props.gasLimit,
125− { 'Sign Transaction' }
130− props.stx.matchWith({
133− const rendered = renderSignedTx(tx.value)
136− <H3 className={'mt-8'}>{'Signed Transaction'}</H3>
137− <Code> {JSON.stringify(rendered, null, 2)} </Code>
145− props.web3.matchWith({
152− disabled={ !props.canApprove }
153− onClick={ () => props.setUserApproval() }
154− state={props.userApproval}>
156− { `I approve this transaction and wish to send.` }
160− prop-size={'xl wide'}
162− disabled={ !props.canSend }
163− onClick={ () => props.handleSubmit() }>
164− { 'Send Transaction' }
171 </React.Fragment>
177 </React.Fragment>