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
cd43e0be
Unverified
Commit
cd43e0be
authored
Aug 03, 2023
by
Brendan Wong
Committed by
GitHub
Aug 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: failing token cloud function tests (#7074)
* fix: failing token cloud function tests * utilize enum from chains
parent
24d00f7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
[[index]].ts
functions/tokens/[[index]].ts
+16
-4
getToken.ts
functions/utils/getToken.ts
+1
-1
No files found.
functions/tokens/[[index]].ts
View file @
cd43e0be
/* eslint-disable import/no-unused-modules */
/* eslint-disable import/no-unused-modules */
import
{
Chain
}
from
'
../../src/graphql/data/__generated__/types-and-hooks
'
import
{
MetaTagInjector
}
from
'
../components/metaTagInjector
'
import
{
MetaTagInjector
}
from
'
../components/metaTagInjector
'
import
getToken
from
'
../utils/getToken
'
import
getToken
from
'
../utils/getToken
'
const
convertTokenAddress
=
(
tokenAddress
:
string
)
=>
{
const
convertTokenAddress
=
(
tokenAddress
:
string
,
networkName
:
string
)
=>
{
return
tokenAddress
&&
tokenAddress
===
'
NATIVE
'
?
'
0x0000000000000000000000000000000000000000
'
:
tokenAddress
if
(
tokenAddress
===
'
NATIVE
'
)
{
switch
(
networkName
)
{
case
Chain
.
Celo
:
return
'
0x471EcE3750Da237f93B8E339c536989b8978a438
'
case
Chain
.
Polygon
:
return
'
0x0000000000000000000000000000000000001010
'
default
:
return
undefined
}
}
return
tokenAddress
}
}
export
const
onRequest
:
PagesFunction
=
async
({
params
,
request
,
next
})
=>
{
export
const
onRequest
:
PagesFunction
=
async
({
params
,
request
,
next
})
=>
{
const
{
index
}
=
params
const
{
index
}
=
params
const
networkName
=
index
[
0
]?.
toString
().
toUpperCase
()
const
networkName
=
index
[
0
]?.
toString
().
toUpperCase
()
const
token
Address
=
convertTokenAddress
(
index
[
1
]?.
toString
()
)
const
token
String
=
index
[
1
]?.
toString
(
)
if
(
!
token
Address
)
{
if
(
!
token
String
)
{
return
next
()
return
next
()
}
}
const
tokenAddress
=
convertTokenAddress
(
tokenString
,
networkName
)
const
tokenPromise
=
getToken
(
networkName
,
tokenAddress
,
request
.
url
)
const
tokenPromise
=
getToken
(
networkName
,
tokenAddress
,
request
.
url
)
const
resPromise
=
next
()
const
resPromise
=
next
()
try
{
try
{
...
...
functions/utils/getToken.ts
View file @
cd43e0be
...
@@ -11,7 +11,7 @@ function formatTitleName(symbol: string, name: string) {
...
@@ -11,7 +11,7 @@ function formatTitleName(symbol: string, name: string) {
return
'
View Token on Uniswap
'
return
'
View Token on Uniswap
'
}
}
export
default
async
function
getToken
(
networkName
:
string
,
tokenAddress
:
string
,
url
:
string
)
{
export
default
async
function
getToken
(
networkName
:
string
,
tokenAddress
:
string
|
undefined
,
url
:
string
)
{
const
{
data
}
=
await
client
.
query
({
const
{
data
}
=
await
client
.
query
({
query
:
TokenDocument
,
query
:
TokenDocument
,
variables
:
{
variables
:
{
...
...
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