Skip to content

Commit a9973f3

Browse files
authored
feat(extension): [LW-8924] use muesliswap proxy for token information (#654)
1 parent 0606572 commit a9973f3

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

apps/browser-extension-wallet/.env.defaults

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ WALLET_INTERVAL_IN_SEC=30
66
DROP_CONSOLE_IN_PRODUCTION=false
77
AVAILABLE_CHAINS=Preprod,Preview,Mainnet
88
ADA_PRICE_POLLING_IN_SEC=60
9+
TOKEN_PRICE_POLLING_IN_SEC=300
910
SAVED_PRICE_DURATION_IN_MINUTES=720
1011

1112
# Feature Flags

apps/browser-extension-wallet/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ WALLET_INTERVAL_IN_SEC=30
66
DROP_CONSOLE_IN_PRODUCTION=false
77
AVAILABLE_CHAINS=Preprod,Preview,Mainnet
88
ADA_PRICE_POLLING_IN_SEC=60
9+
TOKEN_PRICE_POLLING_IN_SEC=300
910
SAVED_PRICE_DURATION_IN_MINUTES=720
1011

1112
# Feature Flags

apps/browser-extension-wallet/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"permissions": ["webRequest", "storage", "tabs", "unlimitedStorage"],
2020
"host_permissions": ["<all_urls>"],
2121
"content_security_policy": {
22-
"extension_pages": "default-src 'self' $LOCALHOST_DEFAULT_SRC; frame-src https://connect.trezor.io/ https://www.youtube-nocookie.com; script-src 'self' 'wasm-unsafe-eval' $LOCALHOST_SCRIPT_SRC; font-src 'self' https://use.typekit.net; object-src 'self'; connect-src $CARDANO_SERVICES_URLS $ADA_HANDLE_URLS https://coingecko.live-mainnet.eks.lw.iog.io https://api.muesliswap.com $LOCALHOST_CONNECT_SRC https://matomo.cw.iog.io/ https://eu.posthog.com/ https://use.typekit.net data:; style-src * 'unsafe-inline'; img-src * data:;"
22+
"extension_pages": "default-src 'self' $LOCALHOST_DEFAULT_SRC; frame-src https://connect.trezor.io/ https://www.youtube-nocookie.com; script-src 'self' 'wasm-unsafe-eval' $LOCALHOST_SCRIPT_SRC; font-src 'self' https://use.typekit.net; object-src 'self'; connect-src $CARDANO_SERVICES_URLS $ADA_HANDLE_URLS https://coingecko.live-mainnet.eks.lw.iog.io https://muesliswap.live-mainnet.eks.lw.iog.io $LOCALHOST_CONNECT_SRC https://matomo.cw.iog.io/ https://eu.posthog.com/ https://use.typekit.net data:; style-src * 'unsafe-inline'; img-src * data:;"
2323
},
2424
"content_scripts": [
2525
{

apps/browser-extension-wallet/src/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type Config = {
2222
WALLET_INTERVAL: number;
2323
CARDANO_SERVICES_URLS: CardanoServiceUrls;
2424
ADA_PRICE_CHECK_INTERVAL: number;
25+
TOKEN_PRICE_CHECK_INTERVAL: number;
2526
AVAILABLE_CHAINS: Wallet.ChainName[];
2627
CEXPLORER_BASE_URL: Record<EnvironmentTypes, string>;
2728
CEXPLORER_URL_PATHS: CExplorerUrlPaths;
@@ -73,6 +74,9 @@ export const config = (): Config => {
7374
ADA_PRICE_CHECK_INTERVAL: !Number.isNaN(Number(process.env.ADA_PRICE_POLLING_IN_SEC))
7475
? Number(process.env.ADA_PRICE_POLLING_IN_SEC) * 1000
7576
: 30 * 1000,
77+
TOKEN_PRICE_CHECK_INTERVAL: !Number.isNaN(Number(process.env.TOKEN_PRICE_POLLING_IN_SEC))
78+
? Number(process.env.TOKEN_PRICE_POLLING_IN_SEC) * 1000
79+
: 300 * 1000,
7680
CARDANO_SERVICES_URLS: {
7781
Mainnet: process.env.CARDANO_SERVICES_URL_MAINNET,
7882
Preprod: process.env.CARDANO_SERVICES_URL_PREPROD,

apps/browser-extension-wallet/src/lib/scripts/background/services/utilityServices.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ const handleOpenBrowser = async (data: OpenBrowserData) => {
8686

8787
const handleChangeTheme = (data: ChangeThemeData) => requestMessage$.next({ type: MessageTypes.CHANGE_THEME, data });
8888

89-
const { ADA_PRICE_CHECK_INTERVAL, SAVED_PRICE_DURATION } = config();
89+
const { ADA_PRICE_CHECK_INTERVAL, SAVED_PRICE_DURATION, TOKEN_PRICE_CHECK_INTERVAL } = config();
9090
const fetchTokenPrices = () => {
9191
// `base-policy-id=&base-tokenname=` for ADA as base token
92-
fetch('https://api.muesliswap.com/list?base-policy-id=&base-tokenname=')
92+
fetch('https://muesliswap.live-mainnet.eks.lw.iog.io/list?base-policy-id=&base-tokenname=')
9393
.then(async (response) => {
9494
const tokens: TokenAPIResponse[] = await response.json();
9595
const tokenPrices: TokenPrices = new Map();
@@ -169,7 +169,7 @@ fetchAdaPrice();
169169
setInterval(fetchAdaPrice, ADA_PRICE_CHECK_INTERVAL);
170170
if (process.env.USE_TOKEN_PRICING === 'true') {
171171
fetchTokenPrices();
172-
setInterval(fetchTokenPrices, ADA_PRICE_CHECK_INTERVAL);
172+
setInterval(fetchTokenPrices, TOKEN_PRICE_CHECK_INTERVAL);
173173
}
174174

175175
exposeApi<BackgroundService>(

0 commit comments

Comments
 (0)