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
ae9fa925
Commit
ae9fa925
authored
Oct 26, 2018
by
Kenny Tran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do approvals correctly
parent
d15a3cec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
25 deletions
+26
-25
index.js
src/components/CurrencyInputPanel/index.js
+3
-2
AddLiquidity.js
src/pages/Pool/AddLiquidity.js
+7
-7
index.js
src/pages/Send/index.js
+8
-8
index.js
src/pages/Swap/index.js
+8
-8
No files found.
src/components/CurrencyInputPanel/index.js
View file @
ae9fa925
...
@@ -210,15 +210,16 @@ class CurrencyInputPanel extends Component {
...
@@ -210,15 +210,16 @@ class CurrencyInputPanel extends Component {
exchangeAddresses
:
{
fromToken
},
exchangeAddresses
:
{
fromToken
},
web3
,
web3
,
disableUnlock
,
disableUnlock
,
value
,
}
=
this
.
props
;
}
=
this
.
props
;
if
(
disableUnlock
||
!
selectedTokenAddress
||
selectedTokenAddress
===
'
ETH
'
)
{
if
(
disableUnlock
||
!
selectedTokenAddress
||
selectedTokenAddress
===
'
ETH
'
)
{
return
;
return
;
}
}
const
{
value
,
decimals
,
label
}
=
selectors
().
getApprovals
(
selectedTokenAddress
,
account
,
fromToken
[
selectedTokenAddress
]);
const
{
value
:
allowance
,
decimals
,
label
}
=
selectors
().
getApprovals
(
selectedTokenAddress
,
account
,
fromToken
[
selectedTokenAddress
]);
if
(
!
label
||
value
.
isGreaterThan
(
BN
(
10
**
22
)))
{
if
(
!
label
||
allowance
.
isGreaterThanOrEqualTo
(
BN
(
value
*
10
**
decimals
||
0
)))
{
return
;
return
;
}
}
...
...
src/pages/Pool/AddLiquidity.js
View file @
ae9fa925
...
@@ -70,19 +70,19 @@ class AddLiquidity extends Component {
...
@@ -70,19 +70,19 @@ class AddLiquidity extends Component {
isUnapproved
()
{
isUnapproved
()
{
const
{
account
,
exchangeAddresses
,
selectors
}
=
this
.
props
;
const
{
account
,
exchangeAddresses
,
selectors
}
=
this
.
props
;
const
{
outputCurrency
}
=
this
.
state
;
const
{
outputCurrency
,
outputValue
}
=
this
.
state
;
if
(
!
outputCurrency
)
{
if
(
!
outputCurrency
)
{
return
false
;
return
false
;
}
}
const
{
value
,
label
}
=
selectors
().
getApprovals
(
const
{
value
:
allowance
,
label
,
decimals
}
=
selectors
().
getApprovals
(
outputCurrency
,
outputCurrency
,
account
,
account
,
exchangeAddresses
.
fromToken
[
outputCurrency
]
exchangeAddresses
.
fromToken
[
outputCurrency
]
);
);
if
(
!
label
||
value
.
isLessThan
(
BN
(
10
**
22
)))
{
if
(
label
&&
allowance
.
isLessThan
(
BN
(
outputValue
*
10
**
decimals
||
0
)))
{
return
true
;
return
true
;
}
}
...
@@ -183,8 +183,8 @@ class AddLiquidity extends Component {
...
@@ -183,8 +183,8 @@ class AddLiquidity extends Component {
let
inputError
;
let
inputError
;
let
outputError
;
let
outputError
;
let
isValid
=
true
;
let
isValid
=
true
;
const
inputIsZero
=
BN
(
inputValue
).
is
EqualTo
(
BN
(
0
)
);
const
inputIsZero
=
BN
(
inputValue
).
is
Zero
(
);
const
outputIsZero
=
BN
(
outputValue
).
is
EqualTo
(
BN
(
0
)
);
const
outputIsZero
=
BN
(
outputValue
).
is
Zero
(
);
if
(
!
inputValue
||
inputIsZero
||
!
outputValue
||
outputIsZero
||
!
inputCurrency
||
!
outputCurrency
||
this
.
isUnapproved
())
{
if
(
!
inputValue
||
inputIsZero
||
!
outputValue
||
outputIsZero
||
!
inputCurrency
||
!
outputCurrency
||
this
.
isUnapproved
())
{
isValid
=
false
;
isValid
=
false
;
...
@@ -259,8 +259,8 @@ class AddLiquidity extends Component {
...
@@ -259,8 +259,8 @@ class AddLiquidity extends Component {
inputCurrency
,
inputCurrency
,
outputCurrency
,
outputCurrency
,
}
=
this
.
state
;
}
=
this
.
state
;
const
inputIsZero
=
BN
(
inputValue
).
is
EqualTo
(
BN
(
0
)
);
const
inputIsZero
=
BN
(
inputValue
).
is
Zero
(
);
const
outputIsZero
=
BN
(
outputValue
).
is
EqualTo
(
BN
(
0
)
);
const
outputIsZero
=
BN
(
outputValue
).
is
Zero
(
);
if
(
!
inputCurrency
||
!
outputCurrency
)
{
if
(
!
inputCurrency
||
!
outputCurrency
)
{
return
(
return
(
...
...
src/pages/Send/index.js
View file @
ae9fa925
...
@@ -74,8 +74,8 @@ class Send extends Component {
...
@@ -74,8 +74,8 @@ class Send extends Component {
let
outputError
=
''
;
let
outputError
=
''
;
let
isValid
=
true
;
let
isValid
=
true
;
const
validRecipientAddress
=
web3
&&
web3
.
utils
.
isAddress
(
recipient
);
const
validRecipientAddress
=
web3
&&
web3
.
utils
.
isAddress
(
recipient
);
const
inputIsZero
=
BN
(
inputValue
).
is
EqualTo
(
BN
(
0
)
);
const
inputIsZero
=
BN
(
inputValue
).
is
Zero
(
);
const
outputIsZero
=
BN
(
outputValue
).
is
EqualTo
(
BN
(
0
)
);
const
outputIsZero
=
BN
(
outputValue
).
is
Zero
(
);
if
(
!
inputValue
||
inputIsZero
||
!
outputValue
||
outputIsZero
||
!
inputCurrency
||
!
outputCurrency
||
!
recipient
||
this
.
isUnapproved
()
||
!
validRecipientAddress
)
{
if
(
!
inputValue
||
inputIsZero
||
!
outputValue
||
outputIsZero
||
!
inputCurrency
||
!
outputCurrency
||
!
recipient
||
this
.
isUnapproved
()
||
!
validRecipientAddress
)
{
isValid
=
false
;
isValid
=
false
;
...
@@ -100,19 +100,19 @@ class Send extends Component {
...
@@ -100,19 +100,19 @@ class Send extends Component {
isUnapproved
()
{
isUnapproved
()
{
const
{
account
,
exchangeAddresses
,
selectors
}
=
this
.
props
;
const
{
account
,
exchangeAddresses
,
selectors
}
=
this
.
props
;
const
{
inputCurrency
}
=
this
.
state
;
const
{
inputCurrency
,
inputValue
}
=
this
.
state
;
if
(
!
inputCurrency
||
inputCurrency
===
'
ETH
'
)
{
if
(
!
inputCurrency
||
inputCurrency
===
'
ETH
'
)
{
return
false
;
return
false
;
}
}
const
{
value
,
label
}
=
selectors
().
getApprovals
(
const
{
value
:
allowance
,
label
,
decimals
}
=
selectors
().
getApprovals
(
inputCurrency
,
inputCurrency
,
account
,
account
,
exchangeAddresses
.
fromToken
[
inputCurrency
]
exchangeAddresses
.
fromToken
[
inputCurrency
]
);
);
if
(
!
label
||
value
.
isLessThan
(
BN
(
10
**
22
)))
{
if
(
label
&&
allowance
.
isLessThan
(
BN
(
inputValue
*
10
**
decimals
||
0
)))
{
return
true
;
return
true
;
}
}
...
@@ -128,7 +128,7 @@ class Send extends Component {
...
@@ -128,7 +128,7 @@ class Send extends Component {
const
editedValue
=
lastEditedField
===
INPUT
?
this
.
state
.
inputValue
:
this
.
state
.
outputValue
;
const
editedValue
=
lastEditedField
===
INPUT
?
this
.
state
.
inputValue
:
this
.
state
.
outputValue
;
if
(
BN
(
editedValue
).
is
EqualTo
(
BN
(
0
)
))
{
if
(
BN
(
editedValue
).
is
Zero
(
))
{
return
;
return
;
}
}
...
@@ -500,8 +500,8 @@ class Send extends Component {
...
@@ -500,8 +500,8 @@ class Send extends Component {
const
{
label
:
inputLabel
}
=
selectors
().
getBalance
(
account
,
inputCurrency
);
const
{
label
:
inputLabel
}
=
selectors
().
getBalance
(
account
,
inputCurrency
);
const
{
label
:
outputLabel
}
=
selectors
().
getBalance
(
account
,
outputCurrency
);
const
{
label
:
outputLabel
}
=
selectors
().
getBalance
(
account
,
outputCurrency
);
const
validRecipientAddress
=
web3
&&
web3
.
utils
.
isAddress
(
recipient
);
const
validRecipientAddress
=
web3
&&
web3
.
utils
.
isAddress
(
recipient
);
const
inputIsZero
=
BN
(
inputValue
).
is
EqualTo
(
BN
(
0
)
);
const
inputIsZero
=
BN
(
inputValue
).
is
Zero
(
);
const
outputIsZero
=
BN
(
outputValue
).
is
EqualTo
(
BN
(
0
)
);
const
outputIsZero
=
BN
(
outputValue
).
is
Zero
(
);
let
nextStepMessage
;
let
nextStepMessage
;
if
(
inputError
||
outputError
)
{
if
(
inputError
||
outputError
)
{
...
...
src/pages/Swap/index.js
View file @
ae9fa925
...
@@ -71,8 +71,8 @@ class Swap extends Component {
...
@@ -71,8 +71,8 @@ class Swap extends Component {
let
outputError
=
''
;
let
outputError
=
''
;
let
isValid
=
true
;
let
isValid
=
true
;
let
isUnapproved
=
this
.
isUnapproved
();
let
isUnapproved
=
this
.
isUnapproved
();
const
inputIsZero
=
BN
(
inputValue
).
is
EqualTo
(
BN
(
0
)
);
const
inputIsZero
=
BN
(
inputValue
).
is
Zero
(
);
const
outputIsZero
=
BN
(
outputValue
).
is
EqualTo
(
BN
(
0
)
);
const
outputIsZero
=
BN
(
outputValue
).
is
Zero
(
);
if
(
!
inputValue
||
inputIsZero
||
!
outputValue
||
outputIsZero
||
!
inputCurrency
||
!
outputCurrency
||
isUnapproved
)
{
if
(
!
inputValue
||
inputIsZero
||
!
outputValue
||
outputIsZero
||
!
inputCurrency
||
!
outputCurrency
||
isUnapproved
)
{
isValid
=
false
;
isValid
=
false
;
...
@@ -97,19 +97,19 @@ class Swap extends Component {
...
@@ -97,19 +97,19 @@ class Swap extends Component {
isUnapproved
()
{
isUnapproved
()
{
const
{
account
,
exchangeAddresses
,
selectors
}
=
this
.
props
;
const
{
account
,
exchangeAddresses
,
selectors
}
=
this
.
props
;
const
{
inputCurrency
}
=
this
.
state
;
const
{
inputCurrency
,
inputValue
}
=
this
.
state
;
if
(
!
inputCurrency
||
inputCurrency
===
'
ETH
'
)
{
if
(
!
inputCurrency
||
inputCurrency
===
'
ETH
'
)
{
return
false
;
return
false
;
}
}
const
{
value
,
label
}
=
selectors
().
getApprovals
(
const
{
value
:
allowance
,
label
,
decmals
}
=
selectors
().
getApprovals
(
inputCurrency
,
inputCurrency
,
account
,
account
,
exchangeAddresses
.
fromToken
[
inputCurrency
]
exchangeAddresses
.
fromToken
[
inputCurrency
]
);
);
if
(
!
label
||
value
.
isLessThan
(
BN
(
10
**
22
)))
{
if
(
label
&&
allowance
.
isLessThan
(
BN
(
inputValue
*
10
**
decimals
||
0
)))
{
return
true
;
return
true
;
}
}
...
@@ -125,7 +125,7 @@ class Swap extends Component {
...
@@ -125,7 +125,7 @@ class Swap extends Component {
const
editedValue
=
lastEditedField
===
INPUT
?
this
.
state
.
inputValue
:
this
.
state
.
outputValue
;
const
editedValue
=
lastEditedField
===
INPUT
?
this
.
state
.
inputValue
:
this
.
state
.
outputValue
;
if
(
BN
(
editedValue
).
is
EqualTo
(
BN
(
0
)
))
{
if
(
BN
(
editedValue
).
is
Zero
(
))
{
return
;
return
;
}
}
...
@@ -483,8 +483,8 @@ class Swap extends Component {
...
@@ -483,8 +483,8 @@ class Swap extends Component {
outputCurrency
,
outputCurrency
,
}
=
this
.
state
;
}
=
this
.
state
;
const
inputIsZero
=
BN
(
inputValue
).
is
EqualTo
(
BN
(
0
)
);
const
inputIsZero
=
BN
(
inputValue
).
is
Zero
(
);
const
outputIsZero
=
BN
(
outputValue
).
is
EqualTo
(
BN
(
0
)
);
const
outputIsZero
=
BN
(
outputValue
).
is
Zero
(
);
if
(
!
inputCurrency
||
!
outputCurrency
)
{
if
(
!
inputCurrency
||
!
outputCurrency
)
{
return
(
return
(
...
...
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