From f6419a2ff41b9ac1762ac8b49565cd981ac3ff37 Mon Sep 17 00:00:00 2001 From: Danyl Mishyn <35381314+lendihop@users.noreply.github.com> Date: Mon, 2 Dec 2024 13:35:10 +0100 Subject: [PATCH 1/4] TW-1588: Referral links improvements (#1232) * form ux changes * add redux state migration * update version * sync background script constant * cancel migration if advertising checkbox is enabled * fix audit --- package.json | 1 + public/_locales/en/messages.json | 8 ++-- ...se-user-analytics-and-ads-settings.hook.ts | 18 ++++++-- .../setWalletPassword/SetWalletPassword.tsx | 25 ++++++----- src/app/store/index.ts | 2 +- src/app/store/migrations.ts | 19 ++++++++ .../referral-links-settings.tsx | 3 -- yarn.lock | 45 +++---------------- 8 files changed, 58 insertions(+), 63 deletions(-) diff --git a/package.json b/package.json index 5a24deb8db..e0f232dffd 100644 --- a/package.json +++ b/package.json @@ -217,6 +217,7 @@ "source-map": "^0.7.4" }, "resolutions": { + "npm-run-all/cross-spawn": "^7.0.6", "tslib": "^2.4.0", "@types/react": "18.0.15", "@types/react-dev-utils/@types/webpack-dev-server": "^4", diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index dc8aa1fab4..222063a918 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -3160,11 +3160,11 @@ "selectedAccountCannotSignTx": { "message": "Selected account cannot sign transactions" }, "attributes": { "message": "Attributes" }, "properties": { "message": "Properties" }, - "earnRewardsWithAds": { - "message": "Earn Rewards with Ads" + "earnTkeyRewards": { + "message": "Earn TKEY Rewards" }, - "earnRewardsWithAdsDescription": { - "message": "I agree to share my wallet address and IP to receive ads and rewards in TKEY token." + "earnTkeyRewardsDescription": { + "message": "I agree to share my wallet address and IP to receive ads, referral links and rewards in TKEY token." }, "dropdownNoItems": { "message": "No items" diff --git a/src/app/hooks/use-user-analytics-and-ads-settings.hook.ts b/src/app/hooks/use-user-analytics-and-ads-settings.hook.ts index 187eb872ed..1d5b43f177 100644 --- a/src/app/hooks/use-user-analytics-and-ads-settings.hook.ts +++ b/src/app/hooks/use-user-analytics-and-ads-settings.hook.ts @@ -1,24 +1,27 @@ import { useEffect, useRef } from 'react'; import { useShouldShowPartnersPromoSelector } from 'app/store/partners-promotion/selectors'; -import { useAnalyticsEnabledSelector } from 'app/store/settings/selectors'; +import { useReferralLinksEnabledSelector } from 'app/store/settings/selectors'; import { useAnalytics } from 'lib/analytics'; -import { WEBSITES_ANALYTICS_ENABLED } from 'lib/constants'; +import { REPLACE_REFERRALS_ENABLED, WEBSITES_ANALYTICS_ENABLED } from 'lib/constants'; import { AnalyticsEventCategory } from 'lib/temple/analytics-types'; import { useAccountPkh } from 'lib/temple/front'; import { usePassiveStorage } from 'lib/temple/front/storage'; export const useUserAnalyticsAndAdsSettings = () => { const { trackEvent } = useAnalytics(); - const isAnalyticsEnabled = useAnalyticsEnabledSelector(); const isAdsEnabled = useShouldShowPartnersPromoSelector(); + const isReferralLinksEnabled = useReferralLinksEnabledSelector(); const [, setIsWebsitesAnalyticsEnabled] = usePassiveStorage(WEBSITES_ANALYTICS_ENABLED); + const [, setIsReplaceReferralsEnabled] = usePassiveStorage(REPLACE_REFERRALS_ENABLED); + const prevAdsEnabledRef = useRef(isAdsEnabled); const accountPkh = useAccountPkh(); useEffect(() => { setIsWebsitesAnalyticsEnabled(isAdsEnabled); + setIsReplaceReferralsEnabled(isReferralLinksEnabled); // It happens when the wallet is not ready although `registerWallet` promise has been resolved if (typeof accountPkh !== 'string') { @@ -30,5 +33,12 @@ export const useUserAnalyticsAndAdsSettings = () => { } prevAdsEnabledRef.current = isAdsEnabled; - }, [isAdsEnabled, setIsWebsitesAnalyticsEnabled, trackEvent, accountPkh, isAnalyticsEnabled]); + }, [ + isAdsEnabled, + isReferralLinksEnabled, + setIsWebsitesAnalyticsEnabled, + setIsReplaceReferralsEnabled, + trackEvent, + accountPkh + ]); }; diff --git a/src/app/pages/NewWallet/setWalletPassword/SetWalletPassword.tsx b/src/app/pages/NewWallet/setWalletPassword/SetWalletPassword.tsx index ba2d5d7c6d..43d5b96db5 100644 --- a/src/app/pages/NewWallet/setWalletPassword/SetWalletPassword.tsx +++ b/src/app/pages/NewWallet/setWalletPassword/SetWalletPassword.tsx @@ -50,8 +50,8 @@ interface FormData extends TestIDProps { password?: string; repeatPassword?: string; termsAccepted: boolean; - analytics?: boolean; - earnRewardsWithAds: boolean; + analytics: boolean; + earnTkeyRewards: boolean; testID?: string; } @@ -102,7 +102,7 @@ export const SetWalletPassword: FC = ({ defaultValues: { shouldUseKeystorePassword: !isKeystorePasswordWeak, analytics: true, - earnRewardsWithAds: true + earnTkeyRewards: true }, mode: 'onChange' }); @@ -140,20 +140,21 @@ export const SetWalletPassword: FC = ({ : data.password : data.password; try { - const shouldEnableAnalytics = Boolean(data.analytics); - const adsViewEnabled = data.earnRewardsWithAds; + const analyticsEnabled = data.analytics; + const adsViewEnabled = data.earnTkeyRewards; + + setAnalyticsEnabled(analyticsEnabled); setAdsViewEnabled(adsViewEnabled); - setAnalyticsEnabled(shouldEnableAnalytics); - setReferralLinksEnabled(true); + setReferralLinksEnabled(adsViewEnabled); setTermsAccepted(); await setOnboardingCompleted(true); const accountPkh = await registerWallet(password!, formatMnemonic(seedPhrase)); // registerWallet function clears async storages - await putToStorage(REPLACE_REFERRALS_ENABLED, true); + await putToStorage(REPLACE_REFERRALS_ENABLED, adsViewEnabled); await putToStorage(WEBSITES_ANALYTICS_ENABLED, adsViewEnabled); - trackEvent('AnalyticsEnabled', AnalyticsEventCategory.General, { accountPkh }, shouldEnableAnalytics); + trackEvent('AnalyticsEnabled', AnalyticsEventCategory.General, { accountPkh }, analyticsEnabled); trackEvent('AdsEnabled', AnalyticsEventCategory.General, { accountPkh }, adsViewEnabled); navigate('/loading'); @@ -287,10 +288,10 @@ export const SetWalletPassword: FC = ({ } + label={t('earnTkeyRewards')} + labelDescription={} testID={setWalletPasswordSelectors.viewAdsCheckBox} /> diff --git a/src/app/store/index.ts b/src/app/store/index.ts index 152ccb5414..64a5737931 100644 --- a/src/app/store/index.ts +++ b/src/app/store/index.ts @@ -24,7 +24,7 @@ const persistConfigBlacklist: (keyof RootState)[] = SLICES_BLACKLIST; const persistedReducer = persistReducer( { key: 'temple-root', - version: 4, + version: 5, ...storageConfig, stateReconciler: autoMergeLevel2, blacklist: persistConfigBlacklist, diff --git a/src/app/store/migrations.ts b/src/app/store/migrations.ts index 1fbaf66026..54092de9e7 100644 --- a/src/app/store/migrations.ts +++ b/src/app/store/migrations.ts @@ -2,6 +2,7 @@ import { cloneDeep } from 'lodash'; import type { MigrationManifest, PersistedState } from 'redux-persist'; import { toTokenSlug } from 'lib/assets'; +import { IS_MISES_BROWSER } from 'lib/env'; import { isCollectible } from 'lib/metadata'; import { collectiblesMetadataInitialState } from './collectibles-metadata/state'; @@ -99,6 +100,24 @@ export const MIGRATIONS: MigrationManifest = { } }; + return newState; + }, + + '5': (persistedState: PersistedState) => { + if (!persistedState || IS_MISES_BROWSER) return persistedState; + + const typedPersistedState = persistedState as TypedPersistedRootState; + + if (typedPersistedState.partnersPromotion.shouldShowPromotion) return persistedState; + + const newState: TypedPersistedRootState = { + ...typedPersistedState, + settings: { + ...typedPersistedState.settings, + referralLinksEnabled: false + } + }; + return newState; } }; diff --git a/src/app/templates/AdvancedFeatures/referral-links-settings.tsx b/src/app/templates/AdvancedFeatures/referral-links-settings.tsx index 0e219d1d53..b542b609e3 100644 --- a/src/app/templates/AdvancedFeatures/referral-links-settings.tsx +++ b/src/app/templates/AdvancedFeatures/referral-links-settings.tsx @@ -7,12 +7,10 @@ import { useAcceptedTermsVersionSelector, useReferralLinksEnabledSelector } from import { PRIVACY_POLICY_URL, RECENT_TERMS_VERSION, - REPLACE_REFERRALS_ENABLED, TERMS_OF_USE_URL, TERMS_WITH_REFERRALS_VERSION } from 'lib/constants'; import { t, T } from 'lib/i18n'; -import { putToStorage } from 'lib/storage'; import { useConfirm } from 'lib/ui/dialog'; import { EnablingSetting } from '../EnablingSetting'; @@ -65,7 +63,6 @@ export const ReferralLinksSettings = memo(() => { dispatch(setAcceptedTermsVersionAction(RECENT_TERMS_VERSION)); dispatch(setReferralLinksEnabledAction(toChecked)); - putToStorage(REPLACE_REFERRALS_ENABLED, toChecked); }, [acceptedTermsVersion, confirm, dispatch] ); diff --git a/yarn.lock b/yarn.lock index 2c5f84ced4..4b8262e0bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6605,21 +6605,10 @@ cross-fetch@^3.0.4, cross-fetch@^3.1.5: dependencies: node-fetch "^2.6.12" -cross-spawn@^6.0.5: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== - dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" - -cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== +cross-spawn@^6.0.5, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3, cross-spawn@^7.0.6: + version "7.0.6" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" + integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== dependencies: path-key "^3.1.0" shebang-command "^2.0.0" @@ -10738,11 +10727,6 @@ next-tick@1, next-tick@^1.1.0: resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== - no-case@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" @@ -11215,11 +11199,6 @@ path-is-inside@^1.0.2: resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= -path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== - path-key@^3.0.0, path-key@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" @@ -12863,7 +12842,7 @@ selfsigned@^2.4.1: "@types/node-forge" "^1.3.0" node-forge "^1" -"semver@2 || 3 || 4 || 5", semver@^5.5.0: +"semver@2 || 3 || 4 || 5": version "5.7.2" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== @@ -13003,13 +12982,6 @@ shallow-clone@^3.0.0: dependencies: kind-of "^6.0.2" -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg== - dependencies: - shebang-regex "^1.0.0" - shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -13017,11 +12989,6 @@ shebang-command@^2.0.0: dependencies: shebang-regex "^3.0.0" -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== - shebang-regex@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" @@ -14579,7 +14546,7 @@ which-typed-array@^1.1.13, which-typed-array@^1.1.9: gopd "^1.0.1" has-tostringtag "^1.0.0" -which@^1.2.9, which@^1.3.1: +which@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== From 6e8145e85be2f9062a076773534e7c4a2b280fe0 Mon Sep 17 00:00:00 2001 From: Inokentii Mazhara Date: Mon, 2 Dec 2024 14:47:39 +0200 Subject: [PATCH 2/4] TW-1589: Prevent infinite spawning empty divs when an ad fails to load (#1226) * Update @temple-wallet/extension-ads * Update @temple-wallet/extension-ads --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e0f232dffd..b30b5f3756 100644 --- a/package.json +++ b/package.json @@ -233,6 +233,6 @@ "follow-redirects": "^1.15.4" }, "optionalDependencies": { - "@temple-wallet/extension-ads": "9.1.0" + "@temple-wallet/extension-ads": "9.1.1-dev.1589.2" } } diff --git a/yarn.lock b/yarn.lock index 4b8262e0bc..638e8b2c7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3657,10 +3657,10 @@ dependencies: nanoid "^3.1.25" -"@temple-wallet/extension-ads@9.1.0": - version "9.1.0" - resolved "https://registry.yarnpkg.com/@temple-wallet/extension-ads/-/extension-ads-9.1.0.tgz#dc3e786584b26528604f5ffa629090da4a7d0838" - integrity sha512-2m5vgvfp3FnY6mt8e0cf9S1H6uDB7D9OWiiSJv5OJpxuTfo+IGbxmcqmDZVXK292qgxpvuZxCopDZfObZbUg/A== +"@temple-wallet/extension-ads@9.1.1-dev.1589.2": + version "9.1.1-dev.1589.2" + resolved "https://registry.yarnpkg.com/@temple-wallet/extension-ads/-/extension-ads-9.1.1-dev.1589.2.tgz#6f57e8881016769018671ddfcaa2417647d74d45" + integrity sha512-upUeIqLT5L3z5loTM4kTEWLYKldYV7j23aa/tpL/7VNknGGvGWP1wzu3rge+FSYg7pex6swmQpV1URrdpbxLQA== dependencies: axios "^1.7.4" crypto-js "^4.2.0" From 86f39ce02cef1f2fa312b2703ec1bb92b6df7a64 Mon Sep 17 00:00:00 2001 From: Inokentii Mazhara Date: Mon, 2 Dec 2024 15:12:24 +0200 Subject: [PATCH 3/4] TW-1563: Implement theming for native ads that support it (#1227) * TW-1563 Implement theming for native ads that support it * TW-1563 Revert early version increment * Bump tw-ext-ads dep version --------- Co-authored-by: Alex --- package.json | 2 +- .../replace-ads/ads-stack.iframe.ts | 27 +++++++++---- src/lib/ads/configure-ads.ts | 40 +++++++++++++++++-- src/lib/constants.ts | 4 ++ yarn.lock | 8 ++-- 5 files changed, 65 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index b30b5f3756..c7bb96950d 100644 --- a/package.json +++ b/package.json @@ -233,6 +233,6 @@ "follow-redirects": "^1.15.4" }, "optionalDependencies": { - "@temple-wallet/extension-ads": "9.1.1-dev.1589.2" + "@temple-wallet/extension-ads": "10.0.1" } } diff --git a/src/content-scripts/replace-ads/ads-stack.iframe.ts b/src/content-scripts/replace-ads/ads-stack.iframe.ts index 9ab9ef8015..cd274abc05 100644 --- a/src/content-scripts/replace-ads/ads-stack.iframe.ts +++ b/src/content-scripts/replace-ads/ads-stack.iframe.ts @@ -1,11 +1,21 @@ import { configureAds } from 'lib/ads/configure-ads'; import { importExtensionAdsModule } from 'lib/ads/import-extension-ads-module'; -import { ADS_META_SEARCH_PARAM_NAME, AD_CATEGORIES_PARAM_NAME, ORIGIN_SEARCH_PARAM_NAME } from 'lib/constants'; +import { + ADS_META_SEARCH_PARAM_NAME, + AD_CATEGORIES_PARAM_NAME, + FONT_SIZE_SEARCH_PARAM_NAME, + LINE_HEIGHT_SEARCH_PARAM_NAME, + ORIGIN_SEARCH_PARAM_NAME, + THEME_COLOR_SEARCH_PARAM_NAME +} from 'lib/constants'; import { getRulesFromStorage } from './ads-rules'; const usp = new URLSearchParams(window.location.search); const id = usp.get('id'); +const rawThemeColor = usp.get(THEME_COLOR_SEARCH_PARAM_NAME); +const rawFontSize = usp.get(FONT_SIZE_SEARCH_PARAM_NAME); +const rawLineHeight = usp.get(LINE_HEIGHT_SEARCH_PARAM_NAME); const origin = usp.get(ORIGIN_SEARCH_PARAM_NAME) ?? window.location.href; const adsMetadataIds = usp.getAll(ADS_META_SEARCH_PARAM_NAME).map(value => JSON.parse(value)); const adCategories = usp.getAll(AD_CATEGORIES_PARAM_NAME); @@ -16,13 +26,16 @@ configureAds() .then(({ renderAdsStack, rules }) => { const { blacklistedHypelabCampaignsSlugs, permanentAdPlacesRules, adPlacesRules } = rules; - renderAdsStack( - id ?? '', - adsMetadataIds, + renderAdsStack({ + id: id ?? '', + initialAdsMetadata: adsMetadataIds, origin, - permanentAdPlacesRules.length > 0 || adPlacesRules.length > 0, + pageHasPlacesRules: permanentAdPlacesRules.length > 0 || adPlacesRules.length > 0, adCategories, - blacklistedHypelabCampaignsSlugs - ); + hypelabBlacklistedCampaignsSlugs: blacklistedHypelabCampaignsSlugs, + themeColor: rawThemeColor ?? undefined, + fontSize: rawFontSize ? Number(rawFontSize) : undefined, + lineHeight: rawLineHeight ? Number(rawLineHeight) : undefined + }); }) .catch(error => console.error(error)); diff --git a/src/lib/ads/configure-ads.ts b/src/lib/ads/configure-ads.ts index 667038c574..4dce82ea3e 100644 --- a/src/lib/ads/configure-ads.ts +++ b/src/lib/ads/configure-ads.ts @@ -5,14 +5,17 @@ import { ADS_META_SEARCH_PARAM_NAME, AD_CATEGORIES_PARAM_NAME, ContentScriptType, - ORIGIN_SEARCH_PARAM_NAME + FONT_SIZE_SEARCH_PARAM_NAME, + LINE_HEIGHT_SEARCH_PARAM_NAME, + ORIGIN_SEARCH_PARAM_NAME, + THEME_COLOR_SEARCH_PARAM_NAME } from 'lib/constants'; import { APP_VERSION, EnvVars, IS_MISES_BROWSER } from 'lib/env'; import { isTruthy } from 'lib/utils'; import { importExtensionAdsModule } from './import-extension-ads-module'; -// Three interfaces below are copied from '@temple-wallet/extension-ads' to avoid importing it to ensure that a core +// Four interfaces below are copied from '@temple-wallet/extension-ads' to avoid importing it to ensure that a core // build runs without errors. interface AdSource { shouldNotUseStrictContainerLimits?: boolean; @@ -36,6 +39,16 @@ interface AdMetadata { dimensions: AdDimensions; } +interface AdsStackIframeURLParams { + id: string; + adsMetadataIds: any[]; + origin: string; + adCategories: string[]; + themeColor?: string; + fontSize?: number; + lineHeight?: number; +} + const smallTkeyInpageAdUrl = browser.runtime.getURL(`/misc/ad-banners/small-tkey-inpage-ad.png`); const tkeyInpageAdUrl = browser.runtime.getURL(`/misc/ad-banners/tkey-inpage-ad.png`); @@ -45,9 +58,28 @@ const swapTkeyUrl = `${browser.runtime.getURL('fullpage.html')}#/swap?${buildSwa true )}`; -const getAdsStackIframeURL = (id: string, adsMetadataIds: any[], origin: string, adCategories: string[]) => { +const searchParamsNames = { + id: 'id', + themeColor: THEME_COLOR_SEARCH_PARAM_NAME, + fontSize: FONT_SIZE_SEARCH_PARAM_NAME, + lineHeight: LINE_HEIGHT_SEARCH_PARAM_NAME +}; + +const getAdsStackIframeURL = ({ + adsMetadataIds, + origin, + adCategories, + ...plainSearchParamsInput +}: AdsStackIframeURLParams) => { const url = new URL(browser.runtime.getURL('iframes/ads-stack.html')); - url.searchParams.set('id', id); + for (const searchParamsInputName in plainSearchParamsInput) { + const searchParamsInputNameTyped = searchParamsInputName as keyof typeof plainSearchParamsInput; + const key = searchParamsNames[searchParamsInputNameTyped]; + const value = plainSearchParamsInput[searchParamsInputNameTyped]; + if (value || value === 0) { + url.searchParams.set(key, String(value)); + } + } adsMetadataIds.forEach(adMetadataId => url.searchParams.append(ADS_META_SEARCH_PARAM_NAME, JSON.stringify(adMetadataId)) ); diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 054dc9e08b..a7da071008 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -53,3 +53,7 @@ export const searchHotkey = ` (${isMacOS ? '⌘' : 'Ctrl + '}K)`; export const FEE_PER_GAS_UNIT = 0.1; export const LIQUIDITY_BAKING_DEX_ADDRESS = 'KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5'; + +export const THEME_COLOR_SEARCH_PARAM_NAME = 'tc'; +export const FONT_SIZE_SEARCH_PARAM_NAME = 'fs'; +export const LINE_HEIGHT_SEARCH_PARAM_NAME = 'lh'; diff --git a/yarn.lock b/yarn.lock index 638e8b2c7b..b566e0bc27 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3657,10 +3657,10 @@ dependencies: nanoid "^3.1.25" -"@temple-wallet/extension-ads@9.1.1-dev.1589.2": - version "9.1.1-dev.1589.2" - resolved "https://registry.yarnpkg.com/@temple-wallet/extension-ads/-/extension-ads-9.1.1-dev.1589.2.tgz#6f57e8881016769018671ddfcaa2417647d74d45" - integrity sha512-upUeIqLT5L3z5loTM4kTEWLYKldYV7j23aa/tpL/7VNknGGvGWP1wzu3rge+FSYg7pex6swmQpV1URrdpbxLQA== +"@temple-wallet/extension-ads@10.0.1": + version "10.0.1" + resolved "https://registry.yarnpkg.com/@temple-wallet/extension-ads/-/extension-ads-10.0.1.tgz#76a05a83b037ad539d2a67a271ddb1cc35025660" + integrity sha512-rRY2xFvSwJXhLLOeOmxfJqprAGfPtpoWOmFxgF1Rx/f3ajogqNYcYH0dLn8Q3T8Vit2xzr5T4S7BdzDbLijNSQ== dependencies: axios "^1.7.4" crypto-js "^4.2.0" From 4353481d21fbbf387173f60c3827d818fb555cdc Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 2 Dec 2024 15:15:01 +0200 Subject: [PATCH 4/4] Bump version to 1.29 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7bb96950d..b7c9916d3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "temple-wallet", - "version": "1.28.0", + "version": "1.29.0", "private": true, "scripts": { "start-run": "cross-env TS_NODE_PROJECT=\"webpack/tsconfig.json\" webpack --watch --stats errors-warnings",