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
b44ae1a2
Unverified
Commit
b44ae1a2
authored
May 11, 2021
by
Noah Zinsmeister
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up parseCurrencyFromURLParameter
parent
418dcf0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
10 deletions
+9
-10
hooks.test.ts
src/state/swap/hooks.test.ts
+2
-2
hooks.ts
src/state/swap/hooks.ts
+7
-8
No files found.
src/state/swap/hooks.test.ts
View file @
b44ae1a2
...
@@ -25,8 +25,8 @@ describe('hooks', () => {
...
@@ -25,8 +25,8 @@ describe('hooks', () => {
expect
(
expect
(
queryParametersToSwapState
(
parse
(
'
?outputCurrency=invalid
'
,
{
parseArrays
:
false
,
ignoreQueryPrefix
:
true
}))
queryParametersToSwapState
(
parse
(
'
?outputCurrency=invalid
'
,
{
parseArrays
:
false
,
ignoreQueryPrefix
:
true
}))
).
toEqual
({
).
toEqual
({
[
Field
.
INPUT
]:
{
currencyId
:
''
},
[
Field
.
INPUT
]:
{
currencyId
:
'
ETH
'
},
[
Field
.
OUTPUT
]:
{
currencyId
:
'
ETH
'
},
[
Field
.
OUTPUT
]:
{
currencyId
:
''
},
typedValue
:
''
,
typedValue
:
''
,
independentField
:
Field
.
INPUT
,
independentField
:
Field
.
INPUT
,
recipient
:
null
,
recipient
:
null
,
...
...
src/state/swap/hooks.ts
View file @
b44ae1a2
...
@@ -217,9 +217,8 @@ function parseCurrencyFromURLParameter(urlParam: any): string {
...
@@ -217,9 +217,8 @@ function parseCurrencyFromURLParameter(urlParam: any): string {
const
valid
=
isAddress
(
urlParam
)
const
valid
=
isAddress
(
urlParam
)
if
(
valid
)
return
valid
if
(
valid
)
return
valid
if
(
urlParam
.
toUpperCase
()
===
'
ETH
'
)
return
'
ETH
'
if
(
urlParam
.
toUpperCase
()
===
'
ETH
'
)
return
'
ETH
'
if
(
valid
===
false
)
return
'
ETH
'
}
}
return
'
ETH
'
??
'
'
return
''
}
}
function
parseTokenAmountURLParameter
(
urlParam
:
any
):
string
{
function
parseTokenAmountURLParameter
(
urlParam
:
any
):
string
{
...
@@ -244,12 +243,12 @@ function validatedRecipient(recipient: any): string | null {
...
@@ -244,12 +243,12 @@ function validatedRecipient(recipient: any): string | null {
export
function
queryParametersToSwapState
(
parsedQs
:
ParsedQs
):
SwapState
{
export
function
queryParametersToSwapState
(
parsedQs
:
ParsedQs
):
SwapState
{
let
inputCurrency
=
parseCurrencyFromURLParameter
(
parsedQs
.
inputCurrency
)
let
inputCurrency
=
parseCurrencyFromURLParameter
(
parsedQs
.
inputCurrency
)
let
outputCurrency
=
parseCurrencyFromURLParameter
(
parsedQs
.
outputCurrency
)
let
outputCurrency
=
parseCurrencyFromURLParameter
(
parsedQs
.
outputCurrency
)
if
(
inputCurrency
===
outputCurrency
)
{
if
(
inputCurrency
===
''
&&
outputCurrency
===
''
)
{
if
(
typeof
parsedQs
.
outputCurrency
===
'
string
'
)
{
// default to ETH input
inputCurrency
=
'
'
inputCurrency
=
'
ETH
'
}
else
{
}
else
if
(
inputCurrency
===
outputCurrency
)
{
outputCurrency
=
''
// clear output if identical
}
outputCurrency
=
''
}
}
const
recipient
=
validatedRecipient
(
parsedQs
.
recipient
)
const
recipient
=
validatedRecipient
(
parsedQs
.
recipient
)
...
...
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