Commit fdbf1dec authored by Max Alekseenko's avatar Max Alekseenko

replace chain id at init

parent 0f84e8dc
import type { Feature } from './types'; import type { Feature } from './types';
import type { GasRefuelProviderConfig } from 'types/client/gasRefuelProviderConfig'; import type { GasRefuelProviderConfig } from 'types/client/gasRefuelProviderConfig';
import chain from '../chain';
import { getEnvValue, parseEnvJson } from '../utils'; import { getEnvValue, parseEnvJson } from '../utils';
import marketplace from './marketplace'; import marketplace from './marketplace';
...@@ -11,7 +12,7 @@ const title = 'Get gas button'; ...@@ -11,7 +12,7 @@ const title = 'Get gas button';
const config: Feature<{ const config: Feature<{
name: string; name: string;
logoUrl?: string; logoUrl?: string;
urlTemplate: string; url: string;
dappId?: string; dappId?: string;
usdThreshold: number; usdThreshold: number;
}> = (() => { }> = (() => {
...@@ -21,7 +22,7 @@ const config: Feature<{ ...@@ -21,7 +22,7 @@ const config: Feature<{
isEnabled: true, isEnabled: true,
name: value.name, name: value.name,
logoUrl: value.logo, logoUrl: value.logo,
urlTemplate: value.url_template, url: value.url_template.replace('{chainId}', chain.id || ''),
dappId: marketplace.isEnabled ? value.dapp_id : undefined, dappId: marketplace.isEnabled ? value.dapp_id : undefined,
usdThreshold: value.usd_threshold || 1, usdThreshold: value.usd_threshold || 1,
}); });
......
...@@ -21,8 +21,6 @@ import LinkInternal from 'ui/shared/links/LinkInternal'; ...@@ -21,8 +21,6 @@ import LinkInternal from 'ui/shared/links/LinkInternal';
import NativeTokenIcon from 'ui/shared/NativeTokenIcon'; import NativeTokenIcon from 'ui/shared/NativeTokenIcon';
import TextSeparator from 'ui/shared/TextSeparator'; import TextSeparator from 'ui/shared/TextSeparator';
const TEMPLATE_CHAIN_ID = '{chainId}';
const getGasFeature = config.features.getGasButton; const getGasFeature = config.features.getGasButton;
interface Props { interface Props {
...@@ -109,8 +107,7 @@ const AddressBalance = ({ data, isLoading }: Props) => { ...@@ -109,8 +107,7 @@ const AddressBalance = ({ data, isLoading }: Props) => {
}; };
try { try {
const getGasUrlString = getGasFeature.urlTemplate.replace(TEMPLATE_CHAIN_ID, config.chain.id || ''); const getGasUrl = new URL(getGasFeature.url);
const getGasUrl = new URL(getGasUrlString);
getGasUrl.searchParams.append('utm_source', 'blockscout'); getGasUrl.searchParams.append('utm_source', 'blockscout');
getGasUrl.searchParams.append('utm_medium', 'address'); getGasUrl.searchParams.append('utm_medium', 'address');
const dappId = getGasFeature.dappId; const dappId = getGasFeature.dappId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment