-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hub): update loading times of tokens for swaps and pools
- Loading branch information
1 parent
d7dbcb4
commit 9cf95bd
Showing
15 changed files
with
319 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { execSync } = require("child_process"); | ||
const path = require("path"); | ||
|
||
try { | ||
const scriptPath = path.resolve(__dirname, "vercel-local-install.sh"); | ||
console.log("Running local installation script..."); | ||
|
||
execSync(`bash ${scriptPath}`, { | ||
stdio: "inherit", | ||
}); | ||
|
||
console.log("Local installation completed successfully"); | ||
} catch (error) { | ||
console.error("Error during local installation:", error.message); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# if secrets folder exists, copy the static folder to the apps | ||
if [ -d "secrets/static" ]; then | ||
mkdir -p apps/hub/public/internal-env | ||
cp -r secrets/static/* apps/hub/public/internal-env | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Token } from "../types"; | ||
|
||
/** | ||
* fetch and format the token list | ||
*/ | ||
function tokenListToDict(list: Token[]): { [key: string]: Token } { | ||
return list.reduce((acc, item) => { | ||
// @ts-ignore | ||
acc[item.address] = item; | ||
return acc; | ||
}, {}); | ||
} | ||
|
||
const formatTokenList = ( | ||
tokenList: Token[], | ||
externalList: Token[], | ||
chainId: number, | ||
) => { | ||
if (!tokenList) | ||
return { | ||
tokenList: externalList ?? [], | ||
customTokenList: externalList ?? [], | ||
featuredTokenList: [], | ||
tokenDictionary: {}, | ||
}; | ||
const defaultList = tokenList | ||
.filter( | ||
(token: any) => | ||
!token.chainId || Number(token.chainId) === Number(chainId), | ||
) | ||
.map((token: any) => { | ||
return { ...token, default: true }; | ||
}); | ||
|
||
const isFeatured = (tag: string) => tag === "featured"; | ||
|
||
const defaultFeaturedList = defaultList | ||
.filter((token: any) => { | ||
return token.tags.some(isFeatured); | ||
}) | ||
.map((token: any) => { | ||
return { ...token, default: true }; | ||
}); | ||
|
||
const list = [...defaultList, ...(externalList ?? [])]; | ||
|
||
const uniqueList = list.filter( | ||
(item, index) => | ||
list.findIndex((i) => i.address === item.address) === index, | ||
); | ||
|
||
return { | ||
tokenList: uniqueList, | ||
customTokenList: [...(externalList ?? [])], | ||
tokenDictionary: tokenListToDict(list), | ||
featuredTokenList: defaultFeaturedList ?? [], | ||
}; | ||
}; | ||
|
||
export { formatTokenList, tokenListToDict }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.