From 86ea1ff2c84729bc51014a9054cac9bf7d6fa287 Mon Sep 17 00:00:00 2001 From: Inokentii Mazhara Date: Tue, 24 Sep 2024 22:22:20 +0300 Subject: [PATCH 1/5] TW-1539: Remove Marigold and periodic networks (#1197) * TW-1539 Remove Marigold and periodic networks * TW-1539 Remove unused functions * TW-1539 Remove onboarding scenarios from e2e tests * TW-1539 Remove 'Partners promotion' checkbox mentions from e2e tests --- e2e/src/features/create-new-wallet.feature | 46 +----------- e2e/src/features/delegate.feature | 4 +- .../features/import-existing-wallet.feature | 75 +------------------ e2e/src/features/send.feature | 4 +- e2e/src/features/swap.feature | 4 +- e2e/src/features/unlock-screen.feature | 1 - e2e/src/page-objects/index.ts | 2 +- .../pages/general-settings.page.ts | 2 - public/_locales/en/messages.json | 4 - public/_locales/en_GB/messages.json | 4 - public/_locales/fr/messages.json | 4 - public/_locales/pt/messages.json | 4 - public/_locales/tr/messages.json | 4 - public/_locales/uk/messages.json | 4 - public/_locales/zh_CN/messages.json | 4 - public/_locales/zh_TW/messages.json | 4 - src/lib/temple/networks.ts | 37 --------- 17 files changed, 9 insertions(+), 198 deletions(-) diff --git a/e2e/src/features/create-new-wallet.feature b/e2e/src/features/create-new-wallet.feature index 27a11578c2..df4fabd330 100644 --- a/e2e/src/features/create-new-wallet.feature +++ b/e2e/src/features/create-new-wallet.feature @@ -19,7 +19,6 @@ Feature: Create a new wallet And I enter defaultPassword into Password Field on the Register Form page And I enter defaultPassword into Repeat Password Field on the Register Form page And I press Analytics Check Box on the Register Form page - And I press Skip Onboarding Checkbox on the Register Form page And I press Accept Terms Checkbox on the Register Form page And I press Create Button on the Register Form page @@ -32,49 +31,6 @@ Feature: Create a new wallet Then I am on the Home page -@create_new_wallet - Scenario: As a user, I'd like to create a wallet and pass on-boarding - Given I am on the Welcome page - And I press Create New Wallet button on the Welcome page - - And I am on the NewSeedBackup page - And I press Protected Mask on the New Seed Back-up page - And I save my mnemonic - And I press I made Seed Phrase Backup Check Box on the New Seed Back-up page - And I press Next Button on the New Seed Back-up page - - And I am on the VerifyMnemonic page - And I verify my mnemonic - And I press Next Button on the New Seed Verify page - - And I am on the SetWallet page - And I enter defaultPassword into Password Field on the Register Form page - And I enter defaultPassword into Repeat Password Field on the Register Form page - And I press Analytics Check Box on the Register Form page - And I press Accept Terms Checkbox on the Register Form page - And I press Create Button on the Register Form page -# On-boarding passing - And I am on the OnboardingFirstStep page - And I press Next Button on the Onboarding (First Step) page - - And I am on the OnboardingSecondStep page - And I press Next Button on the Onboarding (Second Step) page - - And I am on the OnboardingThirdStep page - And I press Next Button on the Onboarding (Third Step) page - - And I am on the OnboardingFourthStep page - And I press Done Button on the Onboarding (Fourth Step) page - - And I am on the OnboardingCongrats page - And I press Start Button on the Onboarding (Congrats) page - - And I am on the OnRumpModal page - And I press Close Button on the On-ramp Modal page - - And I am on the NewsletterModal page - And I press Close Button on the Newsletter Modal page - - Then I am on the Home page +# TODO: add a scenario for passing an onboarding diff --git a/e2e/src/features/delegate.feature b/e2e/src/features/delegate.feature index 55cfdf43b0..153d998cc4 100644 --- a/e2e/src/features/delegate.feature +++ b/e2e/src/features/delegate.feature @@ -4,8 +4,8 @@ Feature: Delegate Scenario: As a user, i'd like to re-delegate TEZ to a baker Given I have imported an existing account And I press Selected Network Button on the Header page - And I select Marigold Mainnet node in the networks drop-down list on the Header page - And I check that Marigold Mainnet node is selected correctly + And I select Tezos Mainnet node in the networks drop-down list on the Header page + And I check that Tezos Mainnet node is selected correctly And I press Asset Item Apy Button on the Assets page And I am on the DelegateTab page diff --git a/e2e/src/features/import-existing-wallet.feature b/e2e/src/features/import-existing-wallet.feature index 4091f0f5a4..d73d7de289 100644 --- a/e2e/src/features/import-existing-wallet.feature +++ b/e2e/src/features/import-existing-wallet.feature @@ -12,7 +12,6 @@ Feature: Import existing wallet And I am on the SetWallet page And I enter defaultPassword into Password Field on the Register Form page And I enter defaultPassword into Repeat Password Field on the Register Form page - And I press Skip Onboarding Checkbox on the Register Form page And I press Analytics Check Box on the Register Form page And I press Accept Terms Checkbox on the Register Form page And I press Import Button on the Register Form page @@ -24,78 +23,6 @@ Feature: Import existing wallet - Scenario: As a user, I'd like to import wallet and pass on-boarding [Positive] - Given I am on the Welcome page - And I press Import Existing Wallet button on the Welcome page - - And I am on the ImportExistingWallet page - And I enter defaultSeedPhrase mnemonic on the ImportExistingWallet page - And I press Next button on the Import Existing Seed Phrase page - - And I am on the SetWallet page - And I enter defaultPassword into Password Field on the Register Form page - And I enter defaultPassword into Repeat Password Field on the Register Form page - And I press Analytics Check Box on the Register Form page - And I press Accept Terms Checkbox on the Register Form page - And I press Import Button on the Register Form page - - # On-boarding passing - And I am on the OnboardingFirstStep page - And I press Next Button on the Onboarding (First Step) page - - And I am on the OnboardingSecondStep page - And I press Next Button on the Onboarding (Second Step) page - - And I am on the OnboardingThirdStep page - And I press Next Button on the Onboarding (Third Step) page - - And I am on the OnboardingFourthStep page - And I press Done Button on the Onboarding (Fourth Step) page - - And I am on the OnboardingCongrats page - And I press Start Button on the Onboarding (Congrats) page - - And I am on the NewsletterModal page - And I press Close Button on the Newsletter Modal page - - Then I am on the Home page - - - Scenario: As a user, I'd like to switch between onboarding pages and skip it [Negative] - Given I am on the Welcome page - And I press Import Existing Wallet button on the Welcome page - - And I am on the ImportExistingWallet page - And I enter defaultSeedPhrase mnemonic on the ImportExistingWallet page - And I press Next button on the Import Existing Seed Phrase page - - And I am on the SetWallet page - And I enter defaultPassword into Password Field on the Register Form page - And I enter defaultPassword into Repeat Password Field on the Register Form page - And I press Analytics Check Box on the Register Form page - And I press Accept Terms Checkbox on the Register Form page - And I press Import Button on the Register Form page - - # On-boarding passing - And I am on the OnboardingFirstStep page - And I press Next Button on the Onboarding (First Step) page - - And I am on the OnboardingSecondStep page - And I press Next Button on the Onboarding (Second Step) page - - And I am on the OnboardingThirdStep page - And I press Next Button on the Onboarding (Third Step) page - - And I am on the OnboardingFourthStep page - # Returning to the previous page - And I press Back Button on the Page Layout page - - And I am on the OnboardingThirdStep page - And I press Skip Button on the Page Layout page - - And I am on the NewsletterModal page - And I press Close Button on the Newsletter Modal page - - Then I am on the Home page + # TODO: add scenarios for passing onboarding diff --git a/e2e/src/features/send.feature b/e2e/src/features/send.feature index 39211d49a0..9d1b46cfad 100644 --- a/e2e/src/features/send.feature +++ b/e2e/src/features/send.feature @@ -4,8 +4,8 @@ Feature: Send Scenario: As a user, I'd like to send my funds to another account Given I have imported an existing account And I press Selected Network Button on the Header page - And I select Marigold Mainnet node in the networks drop-down list on the Header page - And I check that Marigold Mainnet node is selected correctly + And I select Tezos Mainnet node in the networks drop-down list on the Header page + And I check that Tezos Mainnet node is selected correctly And I press Send Button on the Home page And I am on the Send page diff --git a/e2e/src/features/swap.feature b/e2e/src/features/swap.feature index 3ae553b91f..2ef9a459d8 100644 --- a/e2e/src/features/swap.feature +++ b/e2e/src/features/swap.feature @@ -4,8 +4,8 @@ Feature: Swap Scenario: As a user, i'd like to swap assets Given I have imported an existing account And I press Selected Network Button on the Header page - And I select Marigold Mainnet node in the networks drop-down list on the Header page - And I check that Marigold Mainnet node is selected correctly + And I select Tezos Mainnet node in the networks drop-down list on the Header page + And I check that Tezos Mainnet node is selected correctly And I press Swap Button on the Home page And I am on the Swap page diff --git a/e2e/src/features/unlock-screen.feature b/e2e/src/features/unlock-screen.feature index ad4d773ff9..7365488d95 100644 --- a/e2e/src/features/unlock-screen.feature +++ b/e2e/src/features/unlock-screen.feature @@ -131,7 +131,6 @@ Feature: Unlock Screen And I got the 'Attention!' warning with Alert title Text element on the Alert page And I enter defaultPassword into Password Field on the Register Form page And I enter defaultPassword into Repeat Password Field on the Register Form page - And I press Skip Onboarding Checkbox on the Register Form page And I press Analytics Check Box on the Register Form page And I press Accept Terms Checkbox on the Register Form page And I press Import Button on the Register Form page diff --git a/e2e/src/page-objects/index.ts b/e2e/src/page-objects/index.ts index 3d417a27ef..387d32b31e 100644 --- a/e2e/src/page-objects/index.ts +++ b/e2e/src/page-objects/index.ts @@ -47,7 +47,7 @@ import { UnlockScreenPage } from './pages/unlock-screen.page'; import { VerifyMnemonicPage } from './pages/verify-mnemonic.page'; import { WelcomePage } from './pages/welcome.page'; - +// TODO: add a page for advanced settings export const Pages = { Welcome: new WelcomePage(), ImportExistingWallet: new ImportExistingWalletPage(), diff --git a/e2e/src/page-objects/pages/general-settings.page.ts b/e2e/src/page-objects/pages/general-settings.page.ts index 7727364886..e25f4e217b 100644 --- a/e2e/src/page-objects/pages/general-settings.page.ts +++ b/e2e/src/page-objects/pages/general-settings.page.ts @@ -14,7 +14,6 @@ export class GeneralSettingsPage extends Page { extensionLockUpCheckBox = createPageElement(SettingsGeneralSelectors.extensionLockUpCheckBox); anonymousAnalyticsCheckBox = createPageElement(SettingsGeneralSelectors.anonymousAnalyticsCheckBox); notificationCheckBox = createPageElement(SettingsGeneralSelectors.notificationCheckBox); - partnersPromotion = createPageElement(SettingsGeneralSelectors.partnersPromotion); async isVisible() { await this.languageDropDown.waitForDisplayed(); @@ -24,6 +23,5 @@ export class GeneralSettingsPage extends Page { await this.extensionLockUpCheckBox.waitForDisplayed(); await this.anonymousAnalyticsCheckBox.waitForDisplayed(); await this.notificationCheckBox.waitForDisplayed(); - await this.partnersPromotion.waitForDisplayed(); } } diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 3d7d5dc1e0..613ff289ec 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -640,10 +640,6 @@ "message": "Tezos Mainnet", "description": "Mainnet = main network" }, - "marigoldMainnet": { - "message": "Marigold Mainnet", - "description": "Mainnet = main network" - }, "templeWalletOptions": { "message": "Temple Wallet | Options" }, diff --git a/public/_locales/en_GB/messages.json b/public/_locales/en_GB/messages.json index 35c75fedda..50f45b3046 100644 --- a/public/_locales/en_GB/messages.json +++ b/public/_locales/en_GB/messages.json @@ -500,10 +500,6 @@ "message": "Tezos Mainnet", "description": "Mainnet = main network" }, - "marigoldMainnet": { - "message": "Marigold Mainnet", - "description": "Mainnet = main network" - }, "templeWalletOptions": { "message": "Temple Wallet | Options" }, diff --git a/public/_locales/fr/messages.json b/public/_locales/fr/messages.json index f51020583d..2feeb727a0 100644 --- a/public/_locales/fr/messages.json +++ b/public/_locales/fr/messages.json @@ -478,10 +478,6 @@ "message": "Mainnet Tezos", "description": "Mainnet = main network" }, - "marigoldMainnet": { - "message": "Mainnet Marigold", - "description": "Mainnet = main network" - }, "templeWalletOptions": { "message": "Portefeuille Temple | Options" }, diff --git a/public/_locales/pt/messages.json b/public/_locales/pt/messages.json index b1741fb955..e8f917217d 100644 --- a/public/_locales/pt/messages.json +++ b/public/_locales/pt/messages.json @@ -496,10 +496,6 @@ "message": "Tezos Mainnet", "description": "Mainnet = main network" }, - "marigoldMainnet": { - "message": "Marigold Mainnet", - "description": "Mainnet = main network" - }, "templeWalletOptions": { "message": "Carteira Temple | Opções" }, diff --git a/public/_locales/tr/messages.json b/public/_locales/tr/messages.json index de50af2158..5cfae74055 100644 --- a/public/_locales/tr/messages.json +++ b/public/_locales/tr/messages.json @@ -496,10 +496,6 @@ "message": "Tezos Mainnet", "description": "Mainnet = main network" }, - "marigoldMainnet": { - "message": "Marigold Mainnet", - "description": "Mainnet = main network" - }, "templeWalletOptions": { "message": "Temple Wallet | Seçenekler" }, diff --git a/public/_locales/uk/messages.json b/public/_locales/uk/messages.json index e8979a6327..24ff92d46a 100644 --- a/public/_locales/uk/messages.json +++ b/public/_locales/uk/messages.json @@ -495,10 +495,6 @@ "message": "Tezos Mainnet", "description": "Mainnet = main network" }, - "marigoldMainnet": { - "message": "Marigold Mainnet", - "description": "Mainnet = main network" - }, "templeWalletOptions": { "message": "Temple Wallet | Налаштування" }, diff --git a/public/_locales/zh_CN/messages.json b/public/_locales/zh_CN/messages.json index d48989faef..9df70b1854 100644 --- a/public/_locales/zh_CN/messages.json +++ b/public/_locales/zh_CN/messages.json @@ -478,10 +478,6 @@ "message": "Tezos主网", "description": "Mainnet = main network" }, - "marigoldMainnet": { - "message": "Marigold主网", - "description": "Mainnet = main network" - }, "templeWalletOptions": { "message": "Temple钱包 | 选项" }, diff --git a/public/_locales/zh_TW/messages.json b/public/_locales/zh_TW/messages.json index ca59167a09..1e0bd7242f 100644 --- a/public/_locales/zh_TW/messages.json +++ b/public/_locales/zh_TW/messages.json @@ -478,10 +478,6 @@ "message": "Tezos 主網路", "description": "Mainnet = main network" }, - "marigoldMainnet": { - "message": "Marigold 主網路", - "description": "Mainnet = main network" - }, "templeWalletOptions": { "message": "Temple 錢包 | 選項" }, diff --git a/src/lib/temple/networks.ts b/src/lib/temple/networks.ts index c9561bbee3..0cc3ee4180 100644 --- a/src/lib/temple/networks.ts +++ b/src/lib/temple/networks.ts @@ -1,15 +1,5 @@ import { TempleChainId, TempleNetwork } from 'lib/temple/types'; -const formatDateToRPCFormat = (date: Date) => date.toLocaleDateString('en-GB').split('/').reverse().join('-'); - -const getLastMonday = (date = new Date()) => { - const dateCopy = new Date(date.getTime() - 604800000); - - const nextMonday = new Date(dateCopy.setDate(dateCopy.getDate() + ((7 - dateCopy.getDay() + 1) % 7 || 7))); - - return formatDateToRPCFormat(nextMonday); -}; - export const NETWORK_IDS = new Map([ [TempleChainId.Mainnet, 'mainnet'], [TempleChainId.Ghostnet, 'ghostnet'], @@ -48,15 +38,6 @@ export const NETWORKS: TempleNetwork[] = [ color: '#83b300', disabled: false }, - { - id: 'marigold-mainnet', - nameI18nKey: 'marigoldMainnet', - description: 'Marigold mainnet', - type: 'main', - rpcBaseURL: 'https://mainnet.tezos.marigold.dev', - color: '#48bb78', - disabled: false - }, { id: 'smartpy-mainnet', name: 'SmartPy Mainnet', @@ -85,24 +66,6 @@ export const NETWORKS: TempleNetwork[] = [ color: '#131380', disabled: false }, - { - id: 'monday', - name: 'MondayNet Testnet', - description: `MondayNet ${getLastMonday()}`, - type: 'test', - rpcBaseURL: `https://rpc.mondaynet-${getLastMonday()}.teztnets.xyz/`, - color: '#FBBF24', - disabled: false - }, - { - id: 'daily', - name: 'DailyNet Testnet', - description: 'DailyNet', - type: 'test', - rpcBaseURL: `https://rpc.dailynet-${formatDateToRPCFormat(new Date())}.teztnets.xyz/`, - color: '#FBBF24', - disabled: false - }, { id: 'sandbox', name: 'localhost:8732', From 0be33144c5f71f223f95ee62693ee1a54bcca129 Mon Sep 17 00:00:00 2001 From: Inokentii Mazhara Date: Wed, 25 Sep 2024 14:59:23 +0300 Subject: [PATCH 2/5] TW-1518: Ads replacement algorithm improvement (#1196) * TW-1518 Implement blacklisting Hypelab campaigns * TW-1518 Fix a type error * TW-1518 Change the algorithm for picking ad type * TW-1518 Revert harmful changes * TW-1518 Restore using Persona 321x101 banner as one more fallback * TW-1518 Update @temple-wallet/extension-ads --- package.json | 2 +- src/content-scripts/replace-ads/ads-rules.ts | 15 +- .../replace-ads/ads-stack.iframe.ts | 19 +- src/content-scripts/replace-ads/index.ts | 2 +- src/lib/ads/configure-ads.ts | 223 +++++++++++------- src/lib/constants.ts | 2 + yarn.lock | 8 +- 7 files changed, 176 insertions(+), 95 deletions(-) diff --git a/package.json b/package.json index 98faa808aa..c6d34a16bc 100644 --- a/package.json +++ b/package.json @@ -231,6 +231,6 @@ "follow-redirects": "^1.15.4" }, "optionalDependencies": { - "@temple-wallet/extension-ads": "8.1.1" + "@temple-wallet/extension-ads": "9.0.0-dev.2" } } diff --git a/src/content-scripts/replace-ads/ads-rules.ts b/src/content-scripts/replace-ads/ads-rules.ts index b95cc53ba5..d9b7977f63 100644 --- a/src/content-scripts/replace-ads/ads-rules.ts +++ b/src/content-scripts/replace-ads/ads-rules.ts @@ -4,15 +4,15 @@ import { importExtensionAdsModule } from 'lib/ads/import-extension-ads-module'; import { ALL_ADS_RULES_STORAGE_KEY, ADS_RULES_UPDATE_INTERVAL } from 'lib/constants'; import { fetchFromStorage } from 'lib/storage'; -export const getRulesFromContentScript = memoizee( - async (location: Location) => { +export const getRulesFromStorage = memoizee( + async (locationOrHref: Location | string) => { try { const { transformRawRules } = await importExtensionAdsModule(); const rulesStored = await fetchFromStorage(ALL_ADS_RULES_STORAGE_KEY); if (!rulesStored) throw new Error('No rules for ads found'); - return transformRawRules(location, rulesStored); + return transformRawRules(locationOrHref, rulesStored); } catch (error) { console.error(error); @@ -22,11 +22,16 @@ export const getRulesFromContentScript = memoizee( providersSelectors: [], providersNegativeSelectors: [], elementsToHideOrRemoveRules: [], + blacklistedHypelabCampaignsSlugs: [], timestamp: 0 }; } }, - { maxAge: ADS_RULES_UPDATE_INTERVAL, normalizer: ([location]) => location.href, promise: true } + { + maxAge: ADS_RULES_UPDATE_INTERVAL, + normalizer: ([locationOrHref]) => (typeof locationOrHref === 'string' ? locationOrHref : locationOrHref.href), + promise: true + } ); -export const clearRulesCache = () => getRulesFromContentScript.clear(); +export const clearRulesCache = () => getRulesFromStorage.clear(); diff --git a/src/content-scripts/replace-ads/ads-stack.iframe.ts b/src/content-scripts/replace-ads/ads-stack.iframe.ts index f7c6eb8cb4..9ab9ef8015 100644 --- a/src/content-scripts/replace-ads/ads-stack.iframe.ts +++ b/src/content-scripts/replace-ads/ads-stack.iframe.ts @@ -1,13 +1,28 @@ import { configureAds } from 'lib/ads/configure-ads'; import { importExtensionAdsModule } from 'lib/ads/import-extension-ads-module'; -import { ADS_META_SEARCH_PARAM_NAME, ORIGIN_SEARCH_PARAM_NAME } from 'lib/constants'; +import { ADS_META_SEARCH_PARAM_NAME, AD_CATEGORIES_PARAM_NAME, ORIGIN_SEARCH_PARAM_NAME } from 'lib/constants'; + +import { getRulesFromStorage } from './ads-rules'; const usp = new URLSearchParams(window.location.search); const id = usp.get('id'); 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); configureAds() .then(() => importExtensionAdsModule()) - .then(({ renderAdsStack }) => renderAdsStack(id ?? '', adsMetadataIds, origin)) + .then(async ({ renderAdsStack }) => ({ renderAdsStack, rules: await getRulesFromStorage(origin) })) + .then(({ renderAdsStack, rules }) => { + const { blacklistedHypelabCampaignsSlugs, permanentAdPlacesRules, adPlacesRules } = rules; + + renderAdsStack( + id ?? '', + adsMetadataIds, + origin, + permanentAdPlacesRules.length > 0 || adPlacesRules.length > 0, + adCategories, + blacklistedHypelabCampaignsSlugs + ); + }) .catch(error => console.error(error)); diff --git a/src/content-scripts/replace-ads/index.ts b/src/content-scripts/replace-ads/index.ts index 6177cd706c..ca6d21ec6a 100644 --- a/src/content-scripts/replace-ads/index.ts +++ b/src/content-scripts/replace-ads/index.ts @@ -1 +1 @@ -export { getRulesFromContentScript, clearRulesCache } from './ads-rules'; +export { getRulesFromStorage as getRulesFromContentScript, clearRulesCache } from './ads-rules'; diff --git a/src/lib/ads/configure-ads.ts b/src/lib/ads/configure-ads.ts index 098572b362..667038c574 100644 --- a/src/lib/ads/configure-ads.ts +++ b/src/lib/ads/configure-ads.ts @@ -1,12 +1,41 @@ import browser from 'webextension-polyfill'; import { buildSwapPageUrlQuery } from 'app/pages/Swap/utils/build-url-query'; -import { ADS_META_SEARCH_PARAM_NAME, ContentScriptType, ORIGIN_SEARCH_PARAM_NAME } from 'lib/constants'; +import { + ADS_META_SEARCH_PARAM_NAME, + AD_CATEGORIES_PARAM_NAME, + ContentScriptType, + ORIGIN_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 +// build runs without errors. +interface AdSource { + shouldNotUseStrictContainerLimits?: boolean; + providerName: 'Temple' | 'Persona' | 'HypeLab' | 'SmartyAds'; + native?: boolean; + slug: string; + categories?: string[]; +} + +interface AdDimensions { + width: number; + height: number; + minContainerWidth: number; + minContainerHeight: number; + maxContainerWidth: number; + maxContainerHeight: number; +} + +interface AdMetadata { + source: AdSource; + dimensions: AdDimensions; +} + 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`); @@ -16,13 +45,14 @@ const swapTkeyUrl = `${browser.runtime.getURL('fullpage.html')}#/swap?${buildSwa true )}`; -const getAdsStackIframeURL = (id: string, adsMetadataIds: any[], origin: string) => { +const getAdsStackIframeURL = (id: string, adsMetadataIds: any[], origin: string, adCategories: string[]) => { const url = new URL(browser.runtime.getURL('iframes/ads-stack.html')); url.searchParams.set('id', id); adsMetadataIds.forEach(adMetadataId => url.searchParams.append(ADS_META_SEARCH_PARAM_NAME, JSON.stringify(adMetadataId)) ); url.searchParams.set(ORIGIN_SEARCH_PARAM_NAME, origin); + adCategories.forEach(category => url.searchParams.append(AD_CATEGORIES_PARAM_NAME, category)); return url.toString(); }; @@ -61,7 +91,7 @@ const buildNativeAdsMeta = (containerWidth: number, containerHeight: number) => } ].filter(isTruthy); -const bannerAdsMetaBase = [ +const bannerAdsMetaBase: (AdMetadata | false)[] = [ { source: { providerName: 'SmartyAds' as const, @@ -110,6 +140,52 @@ const bannerAdsMetaBase = [ maxContainerHeight: 300 } }, + { + source: { + providerName: 'HypeLab' as const, + native: false, + slug: IS_MISES_BROWSER ? EnvVars.HYPELAB_MISES_WIDE_PLACEMENT_SLUG : EnvVars.HYPELAB_WIDE_PLACEMENT_SLUG + }, + dimensions: { + width: 728, + height: 90, + minContainerWidth: 727, + minContainerHeight: 89, + maxContainerWidth: Infinity, + maxContainerHeight: 300 + } + }, + { + source: { + providerName: 'Persona' as const, + native: false, + slug: IS_MISES_BROWSER ? EnvVars.PERSONA_ADS_MISES_WIDE_BANNER_UNIT_ID : EnvVars.PERSONA_ADS_WIDE_BANNER_UNIT_ID + }, + dimensions: { + width: 728, + height: 90, + minContainerWidth: 727, + minContainerHeight: 89, + maxContainerWidth: Infinity, + maxContainerHeight: 300 + } + }, + { + source: { + providerName: 'Persona' as const, + slug: IS_MISES_BROWSER + ? EnvVars.PERSONA_ADS_MISES_MEDIUM_BANNER_UNIT_ID + : EnvVars.PERSONA_ADS_MEDIUM_BANNER_UNIT_ID + }, + dimensions: { + width: 600, + height: 160, + minContainerWidth: 599, + minContainerHeight: 159, + maxContainerWidth: 800, + maxContainerHeight: 300 + } + }, { source: { providerName: 'SmartyAds' as const, @@ -174,6 +250,37 @@ const bannerAdsMetaBase = [ maxContainerHeight: Infinity } }, + { + source: { + providerName: 'HypeLab' as const, + native: false, + slug: IS_MISES_BROWSER ? EnvVars.HYPELAB_MISES_HIGH_PLACEMENT_SLUG : EnvVars.HYPELAB_HIGH_PLACEMENT_SLUG + }, + dimensions: { + width: 300, + height: 250, + minContainerWidth: 299, + minContainerHeight: 249, + maxContainerWidth: 700, + maxContainerHeight: Infinity + } + }, + { + source: { + providerName: 'Persona' as const, + slug: IS_MISES_BROWSER + ? EnvVars.PERSONA_ADS_MISES_SQUARISH_BANNER_UNIT_ID + : EnvVars.PERSONA_ADS_SQUARISH_BANNER_UNIT_ID + }, + dimensions: { + width: 300, + height: 250, + minContainerWidth: 299, + minContainerHeight: 249, + maxContainerWidth: 700, + maxContainerHeight: Infinity + } + }, { source: { providerName: 'SmartyAds' as const, @@ -207,82 +314,6 @@ const bannerAdsMetaBase = [ maxContainerHeight: 130 } }, - { - source: { - providerName: 'HypeLab' as const, - native: false, - slug: IS_MISES_BROWSER ? EnvVars.HYPELAB_MISES_WIDE_PLACEMENT_SLUG : EnvVars.HYPELAB_WIDE_PLACEMENT_SLUG - }, - dimensions: { - width: 728, - height: 90, - minContainerWidth: 727, - minContainerHeight: 89, - maxContainerWidth: Infinity, - maxContainerHeight: 300 - } - }, - { - source: { - providerName: 'Temple' as const, - slug: '' - }, - dimensions: { - width: 728, - height: 90, - minContainerWidth: 727, - minContainerHeight: 89, - maxContainerWidth: Infinity, - maxContainerHeight: 300 - } - }, - { - source: { - providerName: 'Persona' as const, - slug: IS_MISES_BROWSER - ? EnvVars.PERSONA_ADS_MISES_MEDIUM_BANNER_UNIT_ID - : EnvVars.PERSONA_ADS_MEDIUM_BANNER_UNIT_ID - }, - dimensions: { - width: 600, - height: 160, - minContainerWidth: 599, - minContainerHeight: 159, - maxContainerWidth: 800, - maxContainerHeight: 300 - } - }, - { - source: { - providerName: 'HypeLab' as const, - native: false, - slug: IS_MISES_BROWSER ? EnvVars.HYPELAB_MISES_HIGH_PLACEMENT_SLUG : EnvVars.HYPELAB_HIGH_PLACEMENT_SLUG - }, - dimensions: { - width: 300, - height: 250, - minContainerWidth: 299, - minContainerHeight: 249, - maxContainerWidth: 700, - maxContainerHeight: Infinity - } - }, - { - source: { - providerName: 'Persona' as const, - slug: IS_MISES_BROWSER - ? EnvVars.PERSONA_ADS_MISES_SQUARISH_BANNER_UNIT_ID - : EnvVars.PERSONA_ADS_SQUARISH_BANNER_UNIT_ID - }, - dimensions: { - width: 300, - height: 250, - minContainerWidth: 299, - minContainerHeight: 249, - maxContainerWidth: 700, - maxContainerHeight: 500 - } - }, { source: { providerName: 'HypeLab' as const, @@ -302,7 +333,8 @@ const bannerAdsMetaBase = [ { source: { providerName: 'Persona' as const, - slug: IS_MISES_BROWSER ? EnvVars.PERSONA_ADS_MISES_BANNER_UNIT_ID : EnvVars.PERSONA_ADS_BANNER_UNIT_ID + slug: IS_MISES_BROWSER ? EnvVars.PERSONA_ADS_MISES_BANNER_UNIT_ID : EnvVars.PERSONA_ADS_BANNER_UNIT_ID, + shouldNotUseStrictContainerLimits: true }, dimensions: { width: 321, @@ -330,6 +362,32 @@ const bannerAdsMetaBase = [ } ]; +const bannerAdsMeta = bannerAdsMetaBase.filter(isTruthy); + +const pickNextAdMetadata = ( + allAdsMetadata: AdMetadata[], + currentAdMetadata: AdMetadata | undefined, + validAdsCounter: number, + pageHasPlacesRules: boolean, + adCategories: string[] +) => { + const currentAdMetadataIndex = currentAdMetadata ? allAdsMetadata.indexOf(currentAdMetadata) : -1; + const isPureCryptoAd = adCategories.length === 1 && adCategories[0] === 'crypto'; + + if ( + !currentAdMetadata || + (!pageHasPlacesRules && !isPureCryptoAd && validAdsCounter > 0 && currentAdMetadataIndex > 0) + ) { + return allAdsMetadata[0]; + } + + if (allAdsMetadata.length === 1) { + return undefined; + } + + return allAdsMetadata[(currentAdMetadataIndex + 1) % allAdsMetadata.length]; +}; + export const configureAds = async () => { const { configureAds: originalConfigureAds } = await importExtensionAdsModule(); originalConfigureAds({ @@ -341,9 +399,10 @@ export const configureAds = async () => { personaIframePath: browser.runtime.getURL('iframes/persona-ad.html'), getAdsStackIframeURL, buildNativeAdsMeta, - bannerAdsMeta: bannerAdsMetaBase.filter(isTruthy), + bannerAdsMeta, extVersion: APP_VERSION, templePassphrase: EnvVars.TEMPLE_ADS_ORIGIN_PASSPHRASE, - isMisesBrowser: IS_MISES_BROWSER + isMisesBrowser: IS_MISES_BROWSER, + pickNextAdMetadata }); }; diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 7e6e351341..98b1a03c3d 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -7,6 +7,8 @@ export enum ContentScriptType { ReferralClick = 'ReferralClick' } +export const AD_CATEGORIES_PARAM_NAME = 'categories'; + export const ORIGIN_SEARCH_PARAM_NAME = 'o'; export const ADS_META_SEARCH_PARAM_NAME = 'ads-meta'; diff --git a/yarn.lock b/yarn.lock index bbcc9c93a4..228ef3e79d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3607,10 +3607,10 @@ dependencies: nanoid "^3.1.25" -"@temple-wallet/extension-ads@8.1.1": - version "8.1.1" - resolved "https://registry.yarnpkg.com/@temple-wallet/extension-ads/-/extension-ads-8.1.1.tgz#cfbca4e245096d39ed728133dd569d30253536f7" - integrity sha512-F05VRE7eg9lUnMu/3KvvRg5pOWAAwH7aI+yg61PnfgRA2XkWr7dM+ZdswTbJw+Bq27u3MnjdaSYMB3MIyPhk9g== +"@temple-wallet/extension-ads@9.0.0-dev.2": + version "9.0.0-dev.2" + resolved "https://registry.yarnpkg.com/@temple-wallet/extension-ads/-/extension-ads-9.0.0-dev.2.tgz#9ba67b3cb01368650f591e5893655a3d8bde95af" + integrity sha512-eUxOuIXqIL5OUYQrXGrZa3pgacNxbmrUzLaaGJofZI5wi0VAVJSvjRfPwvE7KwBGoYw7g3sE2/gIraU/qmzYhA== dependencies: axios "^1.7.4" crypto-js "^4.2.0" From 9a82873fa0eb443086d8a5f591f3aa76f1ccc7fb Mon Sep 17 00:00:00 2001 From: Inokentii Mazhara Date: Mon, 7 Oct 2024 03:04:05 +0300 Subject: [PATCH 3/5] TW-1536: Change some labels for staking section (#1203) --- public/_locales/en/messages.json | 2 +- src/app/pages/Staking/MyStake.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 613ff289ec..665974acc1 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -1095,7 +1095,7 @@ "message": "Earn" }, "delegationPointsHead2": { - "message": "on your Tezos annualy from\nBaking & Stake rewards" + "message": "on your Tezos annually from\nBaking & Stake rewards" }, "delegationPoint1": { "message": "First reward in Tezos will be paid approximately in 36 days." diff --git a/src/app/pages/Staking/MyStake.tsx b/src/app/pages/Staking/MyStake.tsx index 592a8f5fbe..b6c730b849 100644 --- a/src/app/pages/Staking/MyStake.tsx +++ b/src/app/pages/Staking/MyStake.tsx @@ -164,7 +164,7 @@ export const MyStakeTab = memo(() => { className="h-10" onClick={finalizeUnstake} > - Unstake + Finalize ) : requestsAreLoading ? ( From d9b73a8e0badf1daaf3db9c2b574dd913b8b2b1d Mon Sep 17 00:00:00 2001 From: Danyl Mishyn <35381314+lendihop@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:11:55 +0200 Subject: [PATCH 4/5] TW-1565: Increase swap fee and cashback (#1209) --- public/_locales/en/messages.json | 7 ++++++- public/_locales/en_GB/messages.json | 7 ++++++- src/app/templates/SwapForm/SwapForm.tippy.ts | 3 ++- src/app/templates/SwapForm/SwapForm.tsx | 5 +++-- src/lib/route3/constants.ts | 3 ++- src/lib/swap-router/config.ts | 2 -- 6 files changed, 19 insertions(+), 8 deletions(-) delete mode 100644 src/lib/swap-router/config.ts diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 665974acc1..dc8aa1fab4 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -3111,7 +3111,12 @@ "message": "Cashback" }, "swapCashbackDescription": { - "message": "Swap more than 10$ and receive 0.175% from the swapped amount in the TKEY token as a cashback" + "message": "Swap more than 10$$ and receive $text$% from the swapped amount in the TKEY token as a cashback", + "placeholders": { + "text": { + "content": "$1" + } + } }, "jumpInTezos": { "message": "Jump in Tezos right now!" diff --git a/public/_locales/en_GB/messages.json b/public/_locales/en_GB/messages.json index 50f45b3046..9e3a4286cb 100644 --- a/public/_locales/en_GB/messages.json +++ b/public/_locales/en_GB/messages.json @@ -1776,7 +1776,12 @@ "message": "Cashback" }, "swapCashbackDescription": { - "message": "Swap more than 10$ and receive 0.175% from the swapped amount in the TKEY token as a cashback" + "message": "Swap more than 10$$ and receive $text$% from the swapped amount in the TKEY token as a cashback", + "placeholders": { + "text": { + "content": "$1" + } + } }, "subscribeToNewsletter": { "message": "Subscribe to our Newsletter" diff --git a/src/app/templates/SwapForm/SwapForm.tippy.ts b/src/app/templates/SwapForm/SwapForm.tippy.ts index cd9692d825..c47ce1153a 100644 --- a/src/app/templates/SwapForm/SwapForm.tippy.ts +++ b/src/app/templates/SwapForm/SwapForm.tippy.ts @@ -1,4 +1,5 @@ import { t } from 'lib/i18n'; +import { SWAP_CASHBACK_PERCENT } from 'lib/route3/constants'; export const feeInfoTippyProps = { trigger: 'mouseenter', @@ -10,6 +11,6 @@ export const feeInfoTippyProps = { export const cashbackInfoTippyProps = { trigger: 'mouseenter', hideOnClick: false, - content: t('swapCashbackDescription'), + content: t('swapCashbackDescription', [SWAP_CASHBACK_PERCENT]) as string, animation: 'shift-away-subtle' }; diff --git a/src/app/templates/SwapForm/SwapForm.tsx b/src/app/templates/SwapForm/SwapForm.tsx index 77596d550d..13bc3697f5 100644 --- a/src/app/templates/SwapForm/SwapForm.tsx +++ b/src/app/templates/SwapForm/SwapForm.tsx @@ -31,12 +31,13 @@ import { ROUTING_FEE_SLIPPAGE_RATIO, SWAP_THRESHOLD_TO_GET_CASHBACK, TEMPLE_TOKEN, - ATOMIC_INPUT_THRESHOLD_FOR_FEE_FROM_INPUT + ATOMIC_INPUT_THRESHOLD_FOR_FEE_FROM_INPUT, + ROUTING_FEE_PERCENT, + SWAP_CASHBACK_PERCENT } from 'lib/route3/constants'; import { isLiquidityBakingParamsResponse } from 'lib/route3/interfaces'; import { getPercentageRatio } from 'lib/route3/utils/get-percentage-ratio'; import { getRoute3TokenBySlug } from 'lib/route3/utils/get-route3-token-by-slug'; -import { ROUTING_FEE_PERCENT, SWAP_CASHBACK_PERCENT } from 'lib/swap-router/config'; import { useAccount, useTezos } from 'lib/temple/front'; import { atomsToTokens, tokensToAtoms } from 'lib/temple/helpers'; import useTippy from 'lib/ui/useTippy'; diff --git a/src/lib/route3/constants.ts b/src/lib/route3/constants.ts index 28a4670410..e27f5e31e8 100644 --- a/src/lib/route3/constants.ts +++ b/src/lib/route3/constants.ts @@ -8,7 +8,8 @@ export const LIQUIDITY_BAKING_PROXY_CONTRACT = 'KT1WLWMMm9MywjCqnA8wBAYy9QhUE1Lz export const BURN_ADDREESS = 'tz1burnburnburnburnburnburnburjAYjjX'; export const ROUTING_FEE_ADDRESS = 'tz1UbRzhYjQKTtWYvGUWcRtVT4fN3NESDVYT'; -const ROUTING_FEE_PERCENT = 0.35; +export const ROUTING_FEE_PERCENT = 0.6; +export const SWAP_CASHBACK_PERCENT = 0.3; export const ROUTING_FEE_RATIO = getPercentageRatio(ROUTING_FEE_PERCENT); export const ROUTING_FEE_SLIPPAGE_RATIO = 0.995; export const MAX_ROUTING_FEE_CHAINS = 1; diff --git a/src/lib/swap-router/config.ts b/src/lib/swap-router/config.ts deleted file mode 100644 index 27f6e707df..0000000000 --- a/src/lib/swap-router/config.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const ROUTING_FEE_PERCENT = 0.35; -export const SWAP_CASHBACK_PERCENT = 0.175; From 101e2fc1ca5b93fa5f6012cee58bd88c2c3e43aa Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 17 Oct 2024 14:18:50 +0300 Subject: [PATCH 5/5] Bump version to 1.27.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c6d34a16bc..0c1d00ffb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "temple-wallet", - "version": "1.26.0", + "version": "1.27.0", "private": true, "scripts": { "start-run": "cross-env TS_NODE_PROJECT=\"webpack/tsconfig.json\" webpack --watch --stats errors-warnings",