Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
4b4df7ed
Commit
4b4df7ed
authored
Dec 11, 2018
by
Kenny Tran
Committed by
Chi Kei Chan
Dec 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don’t render numbers if decimals is 0 (#135)
parent
7608485f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
45 deletions
+65
-45
AddLiquidity.js
src/pages/Pool/AddLiquidity.js
+5
-1
RemoveLiquidity.js
src/pages/Pool/RemoveLiquidity.js
+38
-28
index.js
src/pages/Send/index.js
+10
-8
index.js
src/pages/Swap/index.js
+12
-8
No files found.
src/pages/Pool/AddLiquidity.js
View file @
4b4df7ed
...
@@ -118,6 +118,10 @@ class AddLiquidity extends Component {
...
@@ -118,6 +118,10 @@ class AddLiquidity extends Component {
}
}
const
{
value
,
decimals
}
=
selectors
().
getBalance
(
account
,
currency
);
const
{
value
,
decimals
}
=
selectors
().
getBalance
(
account
,
currency
);
if
(
!
decimals
)
{
return
''
;
}
return
`Balance:
${
value
.
dividedBy
(
10
**
decimals
).
toFixed
(
4
)}
`
;
return
`Balance:
${
value
.
dividedBy
(
10
**
decimals
).
toFixed
(
4
)}
`
;
}
}
...
@@ -339,7 +343,7 @@ class AddLiquidity extends Component {
...
@@ -339,7 +343,7 @@ class AddLiquidity extends Component {
const
ownedEth
=
ethPer
.
multipliedBy
(
liquidityBalance
).
dividedBy
(
10
**
18
);
const
ownedEth
=
ethPer
.
multipliedBy
(
liquidityBalance
).
dividedBy
(
10
**
18
);
const
ownedToken
=
tokenPer
.
multipliedBy
(
liquidityBalance
).
dividedBy
(
10
**
decimals
);
const
ownedToken
=
tokenPer
.
multipliedBy
(
liquidityBalance
).
dividedBy
(
10
**
decimals
);
if
(
!
label
)
{
if
(
!
label
||
!
decimals
)
{
return
blank
;
return
blank
;
}
}
...
...
src/pages/Pool/RemoveLiquidity.js
View file @
4b4df7ed
...
@@ -151,6 +151,10 @@ class RemoveLiquidity extends Component {
...
@@ -151,6 +151,10 @@ class RemoveLiquidity extends Component {
return
''
;
return
''
;
}
}
const
{
value
,
decimals
}
=
selectors
().
getBalance
(
account
,
exchangeAddress
);
const
{
value
,
decimals
}
=
selectors
().
getBalance
(
account
,
exchangeAddress
);
if
(
!
decimals
)
{
return
''
;
}
return
`Balance:
${
value
.
dividedBy
(
10
**
decimals
).
toFixed
(
7
)}
`
;
return
`Balance:
${
value
.
dividedBy
(
10
**
decimals
).
toFixed
(
7
)}
`
;
};
};
...
@@ -244,42 +248,48 @@ class RemoveLiquidity extends Component {
...
@@ -244,42 +248,48 @@ class RemoveLiquidity extends Component {
const
{
tokenAddress
,
totalSupply
,
value
:
input
}
=
this
.
state
;
const
{
tokenAddress
,
totalSupply
,
value
:
input
}
=
this
.
state
;
const
blank
=
[
<
CurrencyInputPanel
key
=
"
remove-liquidity-input
"
title
=
"
Output
"
description
=
"
(estimated)
"
renderInput
=
{()
=>
(
<
div
className
=
"
remove-liquidity__output
"
><
/div
>
)}
disableTokenSelect
disableUnlock
/>
,
<
OversizedPanel
key
=
"
remove-liquidity-input-under
"
hideBottom
>
<
div
className
=
"
pool__summary-panel
"
>
<
div
className
=
"
pool__exchange-rate-wrapper
"
>
<
span
className
=
"
pool__exchange-rate
"
>
Exchange
Rate
<
/span
>
<
span
>
-
<
/span
>
<
/div
>
<
div
className
=
"
pool__exchange-rate-wrapper
"
>
<
span
className
=
"
swap__exchange-rate
"
>
Current
Pool
Size
<
/span
>
<
span
>
-
<
/span
>
<
/div
>
<
div
className
=
"
pool__exchange-rate-wrapper
"
>
<
span
className
=
"
swap__exchange-rate
"
>
Your
Pool
Share
<
/span
>
<
span
>
-
<
/span
>
<
/div
>
<
/div
>
<
/OversizedPanel
>
];
const
exchangeAddress
=
fromToken
[
tokenAddress
];
const
exchangeAddress
=
fromToken
[
tokenAddress
];
if
(
!
exchangeAddress
||
!
web3
)
{
if
(
!
exchangeAddress
||
!
web3
)
{
return
[
return
blank
;
<
CurrencyInputPanel
key
=
"
remove-liquidity-input
"
title
=
"
Output
"
description
=
"
(estimated)
"
renderInput
=
{()
=>
(
<
div
className
=
"
remove-liquidity__output
"
><
/div
>
)}
disableTokenSelect
disableUnlock
/>
,
<
OversizedPanel
key
=
"
remove-liquidity-input-under
"
hideBottom
>
<
div
className
=
"
pool__summary-panel
"
>
<
div
className
=
"
pool__exchange-rate-wrapper
"
>
<
span
className
=
"
pool__exchange-rate
"
>
Exchange
Rate
<
/span
>
<
span
>
-
<
/span
>
<
/div
>
<
div
className
=
"
pool__exchange-rate-wrapper
"
>
<
span
className
=
"
swap__exchange-rate
"
>
Current
Pool
Size
<
/span
>
<
span
>
-
<
/span
>
<
/div
>
<
div
className
=
"
pool__exchange-rate-wrapper
"
>
<
span
className
=
"
swap__exchange-rate
"
>
Your
Pool
Share
<
/span
>
<
span
>
-
<
/span
>
<
/div
>
<
/div
>
<
/OversizedPanel
>
];
}
}
const
{
value
:
liquidityBalance
}
=
getBalance
(
account
,
exchangeAddress
);
const
{
value
:
liquidityBalance
}
=
getBalance
(
account
,
exchangeAddress
);
const
{
value
:
ethReserve
}
=
getBalance
(
exchangeAddress
);
const
{
value
:
ethReserve
}
=
getBalance
(
exchangeAddress
);
const
{
value
:
tokenReserve
,
decimals
:
tokenDecimals
,
label
}
=
getBalance
(
exchangeAddress
,
tokenAddress
);
const
{
value
:
tokenReserve
,
decimals
:
tokenDecimals
,
label
}
=
getBalance
(
exchangeAddress
,
tokenAddress
);
if
(
!
tokenDecimals
)
{
return
blank
;
}
const
ownership
=
liquidityBalance
.
dividedBy
(
totalSupply
);
const
ownership
=
liquidityBalance
.
dividedBy
(
totalSupply
);
const
ethPer
=
ethReserve
.
dividedBy
(
totalSupply
);
const
ethPer
=
ethReserve
.
dividedBy
(
totalSupply
);
const
tokenPer
=
tokenReserve
.
multipliedBy
(
10
**
(
18
-
tokenDecimals
)).
dividedBy
(
totalSupply
);
const
tokenPer
=
tokenReserve
.
multipliedBy
(
10
**
(
18
-
tokenDecimals
)).
dividedBy
(
totalSupply
);
...
...
src/pages/Send/index.js
View file @
4b4df7ed
...
@@ -682,6 +682,14 @@ class Send extends Component {
...
@@ -682,6 +682,14 @@ class Send extends Component {
);
);
}
}
renderBalance
(
currency
,
balance
,
decimals
)
{
if
(
!
currency
||
decimals
===
0
)
{
return
''
;
}
return
`Balance:
${
balance
.
dividedBy
(
BN
(
10
**
decimals
)).
toFixed
(
4
)}
`
}
render
()
{
render
()
{
const
{
selectors
,
account
}
=
this
.
props
;
const
{
selectors
,
account
}
=
this
.
props
;
const
{
const
{
...
@@ -716,10 +724,7 @@ class Send extends Component {
...
@@ -716,10 +724,7 @@ class Send extends Component {
<
CurrencyInputPanel
<
CurrencyInputPanel
title
=
"
Input
"
title
=
"
Input
"
description
=
{
lastEditedField
===
OUTPUT
?
estimatedText
:
''
}
description
=
{
lastEditedField
===
OUTPUT
?
estimatedText
:
''
}
extraText
=
{
inputCurrency
extraText
=
{
this
.
renderBalance
(
inputCurrency
,
inputBalance
,
inputDecimals
)}
?
`Balance:
${
inputBalance
.
dividedBy
(
BN
(
10
**
inputDecimals
)).
toFixed
(
4
)}
`
:
''
}
onCurrencySelected
=
{
inputCurrency
=>
this
.
setState
({
inputCurrency
},
this
.
recalcForm
)}
onCurrencySelected
=
{
inputCurrency
=>
this
.
setState
({
inputCurrency
},
this
.
recalcForm
)}
onValueChange
=
{
this
.
updateInput
}
onValueChange
=
{
this
.
updateInput
}
selectedTokens
=
{[
inputCurrency
,
outputCurrency
]}
selectedTokens
=
{[
inputCurrency
,
outputCurrency
]}
...
@@ -735,10 +740,7 @@ class Send extends Component {
...
@@ -735,10 +740,7 @@ class Send extends Component {
<
CurrencyInputPanel
<
CurrencyInputPanel
title
=
"
Output
"
title
=
"
Output
"
description
=
{
lastEditedField
===
INPUT
?
estimatedText
:
''
}
description
=
{
lastEditedField
===
INPUT
?
estimatedText
:
''
}
extraText
=
{
outputCurrency
extraText
=
{
this
.
renderBalance
(
outputCurrency
,
outputBalance
,
outputDecimals
)}
?
`Balance:
${
outputBalance
.
dividedBy
(
BN
(
10
**
outputDecimals
)).
toFixed
(
4
)}
`
:
''
}
onCurrencySelected
=
{
outputCurrency
=>
this
.
setState
({
outputCurrency
},
this
.
recalcForm
)}
onCurrencySelected
=
{
outputCurrency
=>
this
.
setState
({
outputCurrency
},
this
.
recalcForm
)}
onValueChange
=
{
this
.
updateOutput
}
onValueChange
=
{
this
.
updateOutput
}
selectedTokens
=
{[
inputCurrency
,
outputCurrency
]}
selectedTokens
=
{[
inputCurrency
,
outputCurrency
]}
...
...
src/pages/Swap/index.js
View file @
4b4df7ed
...
@@ -662,6 +662,14 @@ class Swap extends Component {
...
@@ -662,6 +662,14 @@ class Swap extends Component {
);
);
}
}
renderBalance
(
currency
,
balance
,
decimals
)
{
if
(
!
currency
||
decimals
===
0
)
{
return
''
;
}
return
`Balance:
${
balance
.
dividedBy
(
BN
(
10
**
decimals
)).
toFixed
(
4
)}
`
}
render
()
{
render
()
{
const
{
selectors
,
account
}
=
this
.
props
;
const
{
selectors
,
account
}
=
this
.
props
;
const
{
const
{
...
@@ -678,6 +686,8 @@ class Swap extends Component {
...
@@ -678,6 +686,8 @@ class Swap extends Component {
const
{
inputError
,
outputError
,
isValid
}
=
this
.
validate
();
const
{
inputError
,
outputError
,
isValid
}
=
this
.
validate
();
return
(
return
(
<
div
className
=
"
swap
"
>
<
div
className
=
"
swap
"
>
<
MediaQuery
query
=
"
(max-device-width: 767px)
"
>
<
MediaQuery
query
=
"
(max-device-width: 767px)
"
>
...
@@ -696,10 +706,7 @@ class Swap extends Component {
...
@@ -696,10 +706,7 @@ class Swap extends Component {
<
CurrencyInputPanel
<
CurrencyInputPanel
title
=
"
Input
"
title
=
"
Input
"
description
=
{
lastEditedField
===
OUTPUT
?
estimatedText
:
''
}
description
=
{
lastEditedField
===
OUTPUT
?
estimatedText
:
''
}
extraText
=
{
inputCurrency
extraText
=
{
this
.
renderBalance
(
inputCurrency
,
inputBalance
,
inputDecimals
)}
?
`Balance:
${
inputBalance
.
dividedBy
(
BN
(
10
**
inputDecimals
)).
toFixed
(
4
)}
`
:
''
}
onCurrencySelected
=
{
inputCurrency
=>
this
.
setState
({
inputCurrency
},
this
.
recalcForm
)}
onCurrencySelected
=
{
inputCurrency
=>
this
.
setState
({
inputCurrency
},
this
.
recalcForm
)}
onValueChange
=
{
this
.
updateInput
}
onValueChange
=
{
this
.
updateInput
}
selectedTokens
=
{[
inputCurrency
,
outputCurrency
]}
selectedTokens
=
{[
inputCurrency
,
outputCurrency
]}
...
@@ -715,10 +722,7 @@ class Swap extends Component {
...
@@ -715,10 +722,7 @@ class Swap extends Component {
<
CurrencyInputPanel
<
CurrencyInputPanel
title
=
"
Output
"
title
=
"
Output
"
description
=
{
lastEditedField
===
INPUT
?
estimatedText
:
''
}
description
=
{
lastEditedField
===
INPUT
?
estimatedText
:
''
}
extraText
=
{
outputCurrency
extraText
=
{
this
.
renderBalance
(
outputCurrency
,
outputBalance
,
outputDecimals
)}
?
`Balance:
${
outputBalance
.
dividedBy
(
BN
(
10
**
outputDecimals
)).
toFixed
(
4
)}
`
:
''
}
onCurrencySelected
=
{
outputCurrency
=>
this
.
setState
({
outputCurrency
},
this
.
recalcForm
)}
onCurrencySelected
=
{
outputCurrency
=>
this
.
setState
({
outputCurrency
},
this
.
recalcForm
)}
onValueChange
=
{
this
.
updateOutput
}
onValueChange
=
{
this
.
updateOutput
}
selectedTokens
=
{[
inputCurrency
,
outputCurrency
]}
selectedTokens
=
{[
inputCurrency
,
outputCurrency
]}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment