on master help sign in
Merge branch 'build-int' of github.com:urbit/bridge into build-int
commit96cf81a06c035ad69d3f564c96ba16506876dd21 authorChris Johnson <chris@cjohnson.io> dateWed 13 Mar 2019, 16:50 (8 years ago) parent515bb45782b70a
10 files changed+148−23
src/components/StatelessTransaction.js+48−3 src/style/button.css+23 src/style/extend.css+9−20 src/views/AcceptTransfer.js+10 src/views/CancelTransfer.js+10 src/views/CreateGalaxy.js+10 src/views/IssueChild.js+10 src/views/SetKeys.js+9 src/views/SetProxy.js+10 src/views/Transfer.js+9
src/components/StatelessTransaction.js+48−3
@@ -9,7 +9,7 @@ import { renderSignedTx, signTransaction } from '../lib/txn'
99
1010const StatelessTransaction = props => {
1111 const { web3, gasPrice, gasLimit, nonce, chainId } = props
12− const { setNonce, setChainId, setGasLimit, setGasPrice } = props
12+ const { setNonce, setChainId, setGasLimit, setGasPrice, showGasDetails, toggleGasDetails } = props
1313 const { txn, stx, createUnsignedTxn } = props
1414 const { canSign, canGenerate, canApprove } = props
1515 const { setUserApproval, userApproval } = props
@@ -20,6 +20,10 @@ const StatelessTransaction = props => {
2020 // - TypeError: Cannot read property 'updater' of undefined
2121 // so just modifying the DOM manually here. (https://imgur.com/a/i0Qsyq1)
2222
23+ const handleRangeChange = (e) => {
24+ setGasPrice(e.target.value);
25+ }
26+
2327 const sendTxn = (e) => {
2428 e.target.setAttribute("disabled", true);
2529 let spinner = e.target.querySelectorAll('.btn-spinner')[0];
@@ -61,6 +65,40 @@ const StatelessTransaction = props => {
6165 </React.Fragment>
6266 })
6367
68+ const gasPriceRangeDialogue = (
69+ <React.Fragment>
70+ <div className="mt-12 flex space-between align-baseline">
71+ <div>
72+ <span>Gas Price:</span>
73+ <span className="ml-4 text-700 text-sm">{gasPrice} gwei</span>
74+ </div>
75+ <div className="text-sm">
76+ <span>Max transaction fee: </span>
77+ <span className="text-700">{(gasPrice * gasLimit) / 1000000000} eth</span>
78+ </div>
79+ </div>
80+
81+ <input
82+ className="mt-4"
83+ type="range"
84+ min="2"
85+ max="20"
86+ list="gweiVals"
87+ value={gasPrice}
88+ onChange={handleRangeChange}
89+ />
90+
91+ <div className="flex space-between text-sm mb-8">
92+ <div>Cheap</div>
93+ <div>Fast</div>
94+ </div>
95+ </React.Fragment>
96+ )
97+
98+ const toggleGasDetailsDialogue = (
99+ <a href="javascript:void(0)" onClick={toggleGasDetails}>Gas Details</a>
100+ )
101+
64102 const gasPriceDialogue =
65103 <Input
66104 className={ 'mono mt-4' }
@@ -184,8 +222,15 @@ const StatelessTransaction = props => {
184222 { generateTxnButton }
185223 { unsignedTxnDisplay }
186224
187− { gasPriceDialogue }
188− { gasLimitDialogue }
225+ { gasPriceRangeDialogue }
226+ { toggleGasDetailsDialogue }
227+
228+ { showGasDetails &&
229+ <div>
230+ { gasPriceDialogue }
231+ { gasLimitDialogue }
232+ </div>
233+ }
189234 { onlineParamsDialogue }
190235
191236 { signTxnButton }
src/style/button.css+23
@@ -95,3 +95,26 @@ button[prop-type='solid']:disabled {
9595button[prop-type='solid'][prop-size*='wide'] {
9696 width: 100%;
9797}
98+
99+.btn-spinner {
100+ position: absolute;
101+ display: inline-block;
102+ width: 20px;
103+ height: 20px;
104+ left: -35px;
105+}
106+
107+.btn-spinner::after {
108+ position: absolute;
109+ width: 16px;
110+ height: 16px;
111+ bottom: 0;
112+ content: "◠";
113+ animation: spin linear 1s infinite;
114+ font-size: 20px;
115+ line-height: 20px;
116+}
117+
118+@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
119+@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
120+@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }
src/style/extend.css+9−20
@@ -444,25 +444,14 @@ code {
444444 display: none !important;
445445}
446446
447−.btn-spinner {
448− position: absolute;
449− display: inline-block;
450− width: 20px;
451− height: 20px;
452− left: -35px;
447+.flex {
448+ display: flex;
453449}
454450
455−.btn-spinner::after {
456− position: absolute;
457− width: 16px;
458− height: 16px;
459− bottom: 0;
460− content: "◠";
461− animation: spin linear 1s infinite;
462− font-size: 20px;
463− line-height: 20px;
464−}
465−
466−@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
467−@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
468−@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }
451+.space-between {
452+ justify-content: space-between;
453+}
454+
455+.align-baseline {
456+ align-items: baseline;
457+}
src/views/AcceptTransfer.js+10
@@ -38,6 +38,7 @@ class AcceptTransfer extends React.Component {
3838 userApproval: false,
3939 nonce: '',
4040 gasPrice: '5',
41+ showGasDetails: false,
4142 chainId: '',
4243 gasLimit: '600000',
4344 stx: Nothing(),
@@ -53,6 +54,13 @@ class AcceptTransfer extends React.Component {
5354 this.handleSetChainId = this.handleSetChainId.bind(this)
5455 this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
5556 this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
57+ this.toggleGasDetails = this.toggleGasDetails.bind(this)
58+ }
59+
60+ toggleGasDetails() {
61+ this.setState({
62+ showGasDetails: !this.state.showGasDetails
63+ })
5664 }
5765
5866 componentDidMount() {
@@ -260,6 +268,8 @@ class AcceptTransfer extends React.Component {
260268 gasPrice={state.gasPrice}
261269 chainId={state.chainId}
262270 gasLimit={state.gasLimit}
271+ showGasDetails={state.showGasDetails}
272+ toggleGasDetails={this.toggleGasDetails}
263273 // Checks
264274 userApproval={state.userApproval}
265275 canGenerate={ canGenerate }
src/views/CancelTransfer.js+10
@@ -38,6 +38,7 @@ class CancelTransfer extends React.Component {
3838 userApproval: false,
3939 nonce: '',
4040 gasPrice: '5',
41+ showGasDetails: false,
4142 chainId: '',
4243 gasLimit: '600000',
4344 stx: Maybe.Nothing(),
@@ -52,6 +53,13 @@ class CancelTransfer extends React.Component {
5253 this.handleSetChainId = this.handleSetChainId.bind(this)
5354 this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
5455 this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
56+ this.toggleGasDetails = this.toggleGasDetails.bind(this)
57+ }
58+
59+ toggleGasDetails() {
60+ this.setState({
61+ showGasDetails: !this.state.showGasDetails
62+ })
5563 }
5664
5765 componentDidMount() {
@@ -242,6 +250,8 @@ class CancelTransfer extends React.Component {
242250 gasPrice={state.gasPrice}
243251 chainId={state.chainId}
244252 gasLimit={state.gasLimit}
253+ showGasDetails={state.showGasDetails}
254+ toggleGasDetails={this.toggleGasDetails}
245255 // Checks
246256 userApproval={state.userApproval}
247257 canGenerate={ canGenerate }
src/views/CreateGalaxy.js+10
@@ -64,6 +64,7 @@ class CreateGalaxy extends React.Component {
6464 txApproval: false,
6565 nonce: '',
6666 gasPrice: '5',
67+ showGasDetails: false,
6768 chainId: '',
6869 txInfo: '',
6970 gasLimit: '600000',
@@ -75,6 +76,13 @@ class CreateGalaxy extends React.Component {
7576 this.handleGalaxyNameInput = this.handleGalaxyNameInput.bind(this)
7677 this.confirmAvailability = this.confirmAvailability.bind(this)
7778 this.handleSubmit = this.handleSubmit.bind(this)
79+ this.toggleGasDetails = this.toggleGasDetails.bind(this)
80+ }
81+
82+ toggleGasDetails() {
83+ this.setState({
84+ showGasDetails: !this.state.showGasDetails
85+ })
7886 }
7987
8088 componentDidMount() {
@@ -266,6 +274,8 @@ class CreateGalaxy extends React.Component {
266274 stx={state.stx}
267275 nonce={state.nonce}
268276 gasPrice={state.gasPrice}
277+ showGasDetails={state.showGasDetails}
278+ toggleGasDetails={this.toggleGasDetails}
269279 chainId={state.chainId}
270280 gasLimit={state.gasLimit}
271281 canGenerate={
src/views/IssueChild.js+10
@@ -51,6 +51,7 @@ class IssueChild extends React.Component {
5151 userApproval: false,
5252 nonce: '',
5353 gasPrice: '5',
54+ showGasDetails: false,
5455 chainId: '',
5556 gasLimit: '600000',
5657 txn: Nothing(),
@@ -70,6 +71,13 @@ class IssueChild extends React.Component {
7071 this.handleSetChainId = this.handleSetChainId.bind(this)
7172 this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
7273 this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
74+ this.toggleGasDetails = this.toggleGasDetails.bind(this)
75+ }
76+
77+ toggleGasDetails() {
78+ this.setState({
79+ showGasDetails: !this.state.showGasDetails
80+ })
7381 }
7482
7583 componentDidMount() {
@@ -478,6 +486,8 @@ class IssueChild extends React.Component {
478486 // Tx details
479487 nonce={state.nonce}
480488 gasPrice={state.gasPrice}
489+ showGasDetails={state.showGasDetails}
490+ toggleGasDetails={this.toggleGasDetails}
481491 chainId={state.chainId}
482492 gasLimit={state.gasLimit}
483493 // Checks
src/views/SetKeys.js+9
@@ -45,6 +45,7 @@ class SetKeys extends React.Component {
4545 userApproval: false,
4646 nonce: '',
4747 gasPrice: '5',
48+ showGasDetails: false,
4849 chainId: '',
4950 gasLimit: '600000',
5051 stx: Maybe.Nothing(),
@@ -61,8 +62,14 @@ class SetKeys extends React.Component {
6162 this.handleSetChainId = this.handleSetChainId.bind(this)
6263 this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
6364 this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
65+ this.toggleGasDetails = this.toggleGasDetails.bind(this)
6466 }
6567
68+ toggleGasDetails() {
69+ this.setState({
70+ showGasDetails: !this.state.showGasDetails
71+ })
72+ }
6673
6774 componentDidMount() {
6875 const { props } = this
@@ -338,6 +345,8 @@ class SetKeys extends React.Component {
338345 gasPrice={state.gasPrice}
339346 chainId={state.chainId}
340347 gasLimit={state.gasLimit}
348+ showGasDetails={state.showGasDetails}
349+ toggleGasDetails={this.toggleGasDetails}
341350 // Checks
342351 userApproval={state.userApproval}
343352 canGenerate={ canGenerate }
src/views/SetProxy.js+10
@@ -58,6 +58,7 @@ class SetProxy extends React.Component {
5858 txn: Maybe.Nothing(),
5959 txError: Maybe.Nothing(),
6060 issuingPoint: issuingPoint,
61+ showGasDetails: false,
6162 userApproval: false,
6263 nonce: '',
6364 gasPrice: '5',
@@ -77,6 +78,13 @@ class SetProxy extends React.Component {
7778 this.handleSetChainId = this.handleSetChainId.bind(this)
7879 this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
7980 this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
81+ this.toggleGasDetails = this.toggleGasDetails.bind(this)
82+ }
83+
84+ toggleGasDetails() {
85+ this.setState({
86+ showGasDetails: !this.state.showGasDetails
87+ })
8088 }
8189
8290 componentDidMount() {
@@ -339,6 +347,8 @@ class SetProxy extends React.Component {
339347 gasPrice={state.gasPrice}
340348 chainId={state.chainId}
341349 gasLimit={state.gasLimit}
350+ showGasDetails={state.showGasDetails}
351+ toggleGasDetails={this.toggleGasDetails}
342352 // Checks
343353 userApproval={state.userApproval}
344354 canGenerate={ canGenerate }
src/views/Transfer.js+9
@@ -39,6 +39,7 @@ class Transfer extends React.Component {
3939 userApproval: false,
4040 nonce: '',
4141 gasPrice: '5',
42+ showGasDetails: false,
4243 chainId: '',
4344 gasLimit: '600000',
4445 txn: Maybe.Nothing(),
@@ -55,8 +56,14 @@ class Transfer extends React.Component {
5556 this.handleSetChainId = this.handleSetChainId.bind(this)
5657 this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
5758 this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
59+ this.toggleGasDetails = this.toggleGasDetails.bind(this)
5860 }
5961
62+ toggleGasDetails() {
63+ this.setState({
64+ showGasDetails: !this.state.showGasDetails
65+ })
66+ }
6067
6168 componentDidMount() {
6269 const { props } = this
@@ -311,6 +318,8 @@ class Transfer extends React.Component {
311318 gasPrice={state.gasPrice}
312319 chainId={state.chainId}
313320 gasLimit={state.gasLimit}
321+ showGasDetails={state.showGasDetails}
322+ toggleGasDetails={this.toggleGasDetails}
314323 // Checks
315324 userApproval={state.userApproval}
316325 canGenerate={ canGenerate }