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 sendTxn = (e) => {
19 e.target.setAttribute("disabled", true);
23 const generateButtonColor =
24 Nothing.hasInstance(txn)
28 const signerButtonColor =
29 Nothing.hasInstance(stx)
33 const generateTxnButton =
36 disabled={ !canGenerate }
37 prop-color={ generateButtonColor }
38 prop-size={ 'lg wide' }
39 onClick={ createUnsignedTxn }
41 { 'Generate Transaction' }
44 const unsignedTxnDisplay = txn.matchWith({
48 <H3 className={ 'mt-8' }>
49 { 'Unsigned Transaction' }
52 { JSON.stringify(tx.value, null, 2) }
57 const gasPriceDialogue =
59 className={ 'mono mt-4' }
61 prop-format={ 'innerLabel' }
63 onChange={ setGasPrice }
66 { 'Gas Price (gwei)' }
70 const gasLimitDialogue =
72 className={ 'mono mt-4' }
74 prop-format={ 'innerLabel' }
76 onChange={ setGasLimit }>
84 className={ 'mono mt-4' }
86 prop-format={ 'innerLabel' }
97 className={ 'mono mt-4 mb-8' }
99 prop-format={ 'innerLabel' }
101 onChange={ setChainId }
108 const onlineParamsDialogue = web3.matchWith({
117 const signTxnButton =
119 disabled={ !canSign }
121 prop-size={ 'lg wide' }
122 prop-color={ signerButtonColor }
123 onClick={ () => signTransaction(props) }
125 { 'Sign Transaction' }
128 const signedTxnDisplay = stx.matchWith({
132 <H3 className={ 'mt-8' }>
133 { 'Signed Transaction' }
136 { JSON.stringify(renderSignedTx(tx.value), null, 2) }
141 const confirmButton =
144 disabled={ !canApprove }
145 onClick={ setUserApproval }
146 state={ userApproval }
149 { `I approve this transaction and wish to send.` }
153 const sendTxnButton =
155 prop-size={ 'xl wide' }
157 disabled={ !canSend }
160 { 'Send Transaction' }
163 const sendDialogue = web3.matchWith({
174 { generateTxnButton }
175 { unsignedTxnDisplay }
179 { onlineParamsDialogue }
189export 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