1import { Nothing } from 'folktale/maybe'
2import React from 'react'
4import { Code, H3 } from './Base'
5import { Button } from './Base'
6import { CheckboxButton, Input, InnerLabel } from './Base'
8import { renderSignedTx, signTransaction } from '../lib/txn'
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
18 const generateButtonColor =
19 Nothing.hasInstance(txn)
23 const signerButtonColor =
24 Nothing.hasInstance(stx)
28 const generateTxnButton =
31 disabled={ !canGenerate }
32 prop-color={ generateButtonColor }
33 prop-size={ 'lg wide' }
34 onClick={ createUnsignedTxn }
36 { 'Generate Transaction' }
39 const unsignedTxnDisplay = txn.matchWith({
43 <H3 className={ 'mt-8' }>
44 { 'Unsigned Transaction' }
47 { JSON.stringify(tx.value, null, 2) }
52 const gasPriceDialogue =
54 className={ 'mono mt-4' }
56 prop-format={ 'innerLabel' }
58 onChange={ setGasPrice }
61 { 'Gas Price (gwei)' }
65 const gasLimitDialogue =
67 className={ 'mono mt-4' }
69 prop-format={ 'innerLabel' }
71 onChange={ setGasLimit }>
79 className={ 'mono mt-4' }
81 prop-format={ 'innerLabel' }
92 className={ 'mono mt-4 mb-8' }
94 prop-format={ 'innerLabel' }
96 onChange={ setChainId }
103 const onlineParamsDialogue = web3.matchWith({
112 const signTxnButton =
114 disabled={ !canSign }
116 prop-size={ 'lg wide' }
117 prop-color={ signerButtonColor }
118 onClick={ () => signTransaction(props) }
120 { 'Sign Transaction' }
123 const signedTxnDisplay = stx.matchWith({
127 <H3 className={ 'mt-8' }>
128 { 'Signed Transaction' }
131 { JSON.stringify(renderSignedTx(tx.value), null, 2) }
136 const confirmButton =
139 disabled={ !canApprove }
140 onClick={ setUserApproval }
141 state={ userApproval }
144 { `I approve this transaction and wish to send.` }
148 const sendTxnButton =
150 prop-size={ 'xl wide' }
152 disabled={ !canSend }
153 onClick={ handleSubmit }
155 { 'Send Transaction' }
158 const sendDialogue = web3.matchWith({
169 { generateTxnButton }
170 { unsignedTxnDisplay }
174 { onlineParamsDialogue }
184export default StatelessTransaction
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list