on master help sign in
- remove “handle” from function names
commit2de5d63a1d2f93b4a41311971cf9f5edc2c702fe authorChris Johnson <chris@cjohnson.io> dateWed 3 Apr 2019, 18:09 (8 years ago) parente421877
2 files changed+34−33
src/bridge/components/StatelessTransaction.js+33−32 src/bridge/views/SetProxy.js+1−1
src/bridge/components/StatelessTransaction.js+33−32
@@ -34,16 +34,17 @@ class StatelessTransaction extends React.Component {
3434 txError: Nothing(),
3535 }
3636
37− this.handleCreateUnsignedTxn = this.handleCreateUnsignedTxn.bind(this)
38− this.handleSubmit = this.handleSubmit.bind(this)
39− this.handleSetUserApproval = this.handleSetUserApproval.bind(this)
40− this.handleSetTxn = this.handleSetTxn.bind(this)
37+ this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
38+ this.submit = this.submit.bind(this)
39+ this.setUserApproval = this.setUserApproval.bind(this)
40+ this.setTxn = this.setTxn.bind(this)
4141 this.setStx = this.setStx.bind(this)
4242 this.sendTxn = this.sendTxn.bind(this)
43− this.handleSetNonce = this.handleSetNonce.bind(this)
44− this.handleSetChainId = this.handleSetChainId.bind(this)
45− this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
46− this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
43+ this.setNonce = this.setNonce.bind(this)
44+ this.setChainId = this.setChainId.bind(this)
45+ this.setGasPrice = this.setGasPrice.bind(this)
46+ this.setGasLimit = this.setGasLimit.bind(this)
47+ this.rangeChange = this.rangeChange.bind(this)
4748 this.toggleGasDetails = this.toggleGasDetails.bind(this)
4849 }
4950
@@ -82,7 +83,7 @@ class StatelessTransaction extends React.Component {
8283 });
8384 }
8485
85− handleSubmit(){
86+ submit(){
8687 const { props, state } = this
8788 sendSignedTransaction(props.web3.value, state.stx)
8889 .then(sent => {
@@ -96,7 +97,7 @@ class StatelessTransaction extends React.Component {
9697 })
9798 }
9899
99− handleSetUserApproval(){
100+ setUserApproval(){
100101 const {state} = this
101102 this.setState({ userApproval: !state.userApproval })
102103 }
@@ -114,16 +115,16 @@ class StatelessTransaction extends React.Component {
114115 })
115116 }
116117
117− handleSetTxn(txn){
118+ setTxn(txn){
118119 this.setState({ txn })
119120 }
120121
121− handleCreateUnsignedTxn() {
122+ createUnsignedTxn() {
122123 const txn = this.props.createUnsignedTxn()
123124 this.setState({ txn })
124125 }
125126
126− handleClearTxn() {
127+ clearTxn() {
127128 this.setState({
128129 userApproval: false,
129130 txn: Nothing(),
@@ -131,31 +132,31 @@ class StatelessTransaction extends React.Component {
131132 })
132133 }
133134
134− handleSetNonce(nonce){
135+ setNonce(nonce){
135136 this.setState({ nonce })
136− this.handleClearStx()
137+ this.clearStx()
137138 }
138139
139− handleSetChainId(chainId){
140+ setChainId(chainId){
140141 this.setState({ chainId })
141− this.handleClearStx()
142+ this.clearStx()
142143 }
143144
144− handleSetGasPrice(gasPrice) {
145+ setGasPrice(gasPrice) {
145146 this.setState({ gasPrice })
146− this.handleClearStx()
147+ this.clearStx()
147148 }
148149
149− handleRangeChange(e) {
150− this.handleSetGasPrice(e.target.value);
150+ rangeChange(e) {
151+ this.setGasPrice(e.target.value);
151152 }
152153
153− handleSetGasLimit(gasLimit){
154+ setGasLimit(gasLimit){
154155 this.setState({ gasLimit })
155− this.handleClearStx()
156+ this.clearStx()
156157 }
157158
158− handleClearStx() {
159+ clearStx() {
159160 this.setState({
160161 userApproval: false,
161162 stx: Nothing(),
@@ -163,7 +164,7 @@ class StatelessTransaction extends React.Component {
163164 }
164165
165166 // TODO: Investigate
166− // setState doesn't seem to work in SetProxy/handleSubmit;
167+ // setState doesn't seem to work in SetProxy/submit;
167168 // - TypeError: Cannot read property 'updater' of undefined
168169 // so just modifying the DOM manually here. (https://imgur.com/a/i0Qsyq1)
169170
@@ -171,17 +172,17 @@ class StatelessTransaction extends React.Component {
171172 e.target.setAttribute("disabled", true);
172173 let spinner = e.target.querySelectorAll('.btn-spinner')[0];
173174 spinner.classList.remove('hide');
174− this.handleSubmit()
175+ this.submit()
175176 }
176177
177178 render() {
178179 const { web3, canGenerate } = this.props
179180 const { gasPrice, gasLimit, nonce, chainId,
180− txn, stx, userApproval } = this.state
181+ txn, stx, userApproval, showGasDetails } = this.state
181182
182183 const { setNonce, setChainId, setGasLimit, setGasPrice,
183− handleSubmit, showGasDetails, toggleGasDetails, handleSetUserApproval,
184− sendTxn, handleCreateUnsignedTxn } = this
184+ submit, toggleGasDetails, setUserApproval,
185+ sendTxn, createUnsignedTxn } = this
185186
186187 const { state } = this
187188
@@ -205,7 +206,7 @@ class StatelessTransaction extends React.Component {
205206 disabled={ !canGenerate }
206207 prop-color={ generateButtonColor }
207208 prop-size={ 'lg wide' }
208− onClick={ handleCreateUnsignedTxn }
209+ onClick={ createUnsignedTxn }
209210 >
210211 { 'Generate Transaction' }
211212 </Button>
@@ -243,7 +244,7 @@ class StatelessTransaction extends React.Component {
243244 max="20"
244245 list="gweiVals"
245246 value={gasPrice}
246− onChange={this.handleRangeChange}
247+ onChange={this.rangeChange}
247248 />
248249
249250 <div className="flex space-between text-sm mb-8">
@@ -345,7 +346,7 @@ class StatelessTransaction extends React.Component {
345346 <CheckboxButton
346347 className={ 'mt-8' }
347348 disabled={ !canApprove }
348− onClick={ handleSetUserApproval }
349+ onClick={ setUserApproval }
349350 state={ userApproval }
350351 >
351352 <div>
src/bridge/views/SetProxy.js+1−1
@@ -56,7 +56,7 @@ class SetProxy extends React.Component {
5656 handleAddressInput(proxyAddress) {
5757 this.setState({ proxyAddress })
5858
59− this.statelessRef.current.handleClearTxn()
59+ this.statelessRef.current.clearTxn()
6060 }
6161
6262 createUnsignedTxn(proxyAddress) {