Skip to content

Commit

Permalink
Merge branch 'develop' into l10n_develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro authored Jun 5, 2024
2 parents 5676b7d + 4789d91 commit 32f3b47
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 19 deletions.
2 changes: 2 additions & 0 deletions packages/desktop/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import { _ } from '@core/i18n'
import { getAndUpdateShimmerEvmTokensMetadata } from '@core/market/actions'
import { initializeWalletConnect } from '@auxiliary/wallet-connect/actions'
import { getAndUpdateCountryCode } from '@auxiliary/country/actions'
$: $activeProfile, saveActiveProfile()
Expand All @@ -50,6 +51,7 @@
let splash = true
void setupI18n({ fallbackLocale: 'en', initialLocale: $appSettings.language })
void getAndUpdateCountryCode()
onMount(async () => {
if (features.analytics.appStart.enabled) {
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/features/onboarding.features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const onboardingFeaturesForIota: IOnboardingFeaturesForNetwork = {
},
},
defaultIscChains: {
enabled: false,
enabled: true,
},
defaultEvmChains: {
enabled: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "desktop",
"productName": "Bloom",
"version": "1.0.3",
"version": "1.0.4",
"description": "Simple and secure web3 wallet for the IOTA and Shimmer ecosystem",
"main": "public/build/main.process.js",
"repository": "[email protected]:bloomwalletio/bloom.git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
} from '@core/router'
import { isDashboardSideBarExpanded } from '@core/ui'
import { IDashboardSidebarTab } from '@desktop/routers'
import features from '@features/features'
import { Logo } from '@ui'
import { campaignsRouter } from '../campaigns'
import LedgerStatusTile from './LedgerStatusTile.svelte'
import StrongholdStatusTile from './StrongholdStatusTile.svelte'
import { BackupToast, VersionToast } from './toasts'
import { isFeatureEnabled, isFeatureNotGeoFenced } from '@lib/features/utils'
let expanded = true
function toggleExpand(): void {
Expand All @@ -38,7 +38,7 @@
route: DashboardRoute.Wallet,
onClick: openWallet,
},
...(features?.collectibles?.enabled && profileFeatures?.collectibles
...(isFeatureEnabled(DashboardRoute.Collectibles) && profileFeatures?.collectibles
? [
{
icon: IconName.Image,
Expand All @@ -48,7 +48,7 @@
},
]
: []),
...(features?.governance?.enabled && profileFeatures?.governance
...(isFeatureEnabled(DashboardRoute.Governance) && profileFeatures?.governance
? [
{
icon: IconName.Bank,
Expand All @@ -58,7 +58,7 @@
},
]
: []),
...(features?.campaigns?.enabled && profileFeatures?.campaigns
...(isFeatureEnabled(DashboardRoute.Campaigns) && profileFeatures?.campaigns
? [
{
icon: IconName.Trophy,
Expand All @@ -68,7 +68,9 @@
},
]
: []),
...(features?.buySell?.enabled && profileFeatures?.buySell
...(isFeatureEnabled(DashboardRoute.BuySell) &&
isFeatureNotGeoFenced(DashboardRoute.BuySell) &&
profileFeatures?.buySell
? [
{
icon: IconName.ArrowDownUp,
Expand All @@ -83,7 +85,7 @@
},
]
: []),
...(features?.developerTools?.enabled && profileFeatures?.developer
...(isFeatureEnabled('developerTools') && profileFeatures?.developer
? [
{
icon: IconName.Developer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { activeProfile, updateActiveProfile } from '@core/profile/stores'
import { DashboardRoute } from '@core/router'
import SettingsSection from '../SettingsSection.svelte'
import { isFeatureNotGeoFenced, isFeatureNotGeoFenced } from '@lib/features/utils'
const features = $activeProfile?.features ?? {
[DashboardRoute.Wallet]: true,
Expand Down Expand Up @@ -47,12 +48,14 @@
label={localize('tabs.campaigns')}
bind:checked={features[DashboardRoute.Campaigns]}
/>
<Checkbox
size="md"
textType="base"
label={localize('tabs.buySell')}
bind:checked={features[DashboardRoute.BuySell]}
/>
{#if isFeatureNotGeoFenced(DashboardRoute.BuySell)}
<Checkbox
size="md"
textType="base"
label={localize('tabs.buySell')}
bind:checked={features[DashboardRoute.BuySell]}
/>
{/if}
<div class="flex flex-row space-x-2 items-center">
<Checkbox
size="md"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { CountryApi } from '../api'
import { updateCountryCode } from '../stores'

export async function getAndUpdateCountryCode(): Promise<void> {
const api = new CountryApi()
const countryCode = await api.getCountryCode()
updateCountryCode(countryCode)
}
1 change: 1 addition & 0 deletions packages/shared/src/lib/auxiliary/country/actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './getAndUpdateCountryCode'
42 changes: 42 additions & 0 deletions packages/shared/src/lib/auxiliary/country/api/country.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { BaseApi } from '@core/utils'

interface IIpApiResponse {
ip: string
network: string
version: string
city: string
region: string
region_code: string
country: string
country_name: string
country_code: string
country_code_iso3: string
country_capital: string
country_tld: string
continent_code: string
in_eu: boolean
postal: string
latitude: number
longitude: number
timezone: string
utc_offset: string
country_calling_code: string
currency: string
currency_name: string
languages: string
country_area: number
country_population: number
asn: string
org: string
}

export class CountryApi extends BaseApi {
constructor() {
super('https://ipapi.co')
}

async getCountryCode(): Promise<string | undefined> {
const ipData = await this.get<IIpApiResponse>('json')
return ipData?.country_code
}
}
1 change: 1 addition & 0 deletions packages/shared/src/lib/auxiliary/country/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './country.api'
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { writable } from 'svelte/store'

export const countryCode = writable<string | undefined>(undefined)

export function updateCountryCode(_countryCode: string | undefined): void {
if (_countryCode) {
countryCode?.set(_countryCode)
}
}
1 change: 1 addition & 0 deletions packages/shared/src/lib/auxiliary/country/stores/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './country-code.store'
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export interface IAppParameters {
allowlists: {
urls: string[]
}
geoFence: {
buySell: string[]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
},
"allowlists": {
"urls": ["https://tideprotocol.infura-ipfs.io"]
},
"geoFence": {
"buySell": ["GB"]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppStage } from '@core/app/enums'

export const PROFILE_VERSION: Record<AppStage, number> = {
[AppStage.ALPHA]: 20,
[AppStage.ALPHA]: 21,
[AppStage.BETA]: 1,
[AppStage.PROD]: 11,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DEFAULT_ISC_CHAINS_CONFIGURATIONS, SupportedStardustNetworkId } from '@core/network'
import { IPersistedProfile } from '@core/profile/interfaces'

export function addDefaultIscChainsToIotaProfiles(profile: IPersistedProfile): void {
if (profile.network.id !== SupportedStardustNetworkId.Iota) {
return
}

const chainConfiguration = DEFAULT_ISC_CHAINS_CONFIGURATIONS[SupportedStardustNetworkId.Iota]

profile.network = {
...profile.network,
chainConfigurations: chainConfiguration ? [chainConfiguration] : [],
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IPersistedProfile } from '../../interfaces'
import { migrateEvmContacts } from '../../migrations/actions/migrateEvmContacts'
import { IPersistedProfile } from '@core/profile/interfaces'
import { addDefaultIscChainsToIotaProfiles } from '../actions/addDefaultIscChainsToIotaProfiles'

export function alphaProfileMigration19To20(existingProfile: unknown): Promise<void> {
const profile = existingProfile as IPersistedProfile

migrateEvmContacts(profile)
addDefaultIscChainsToIotaProfiles(profile)

return Promise.resolve()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IPersistedProfile } from '@core/profile/interfaces'
import { migrateEvmContacts } from '../../migrations/actions/migrateEvmContacts'

export function alphaProfileMigration20To21(existingProfile: unknown): Promise<void> {
const profile = existingProfile as IPersistedProfile

migrateEvmContacts(profile)

return Promise.resolve()
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { alphaProfileMigration17To18 } from './alpha-profile-migration-17-to-18'
import { alphaProfileMigration18To19 } from './alpha-profile-migration-18-to-19'
import { alphaProfileMigration19To20 } from './alpha-profile-migration-19-to-20'
import { alphaProfileMigration2To3 } from './alpha-profile-migration-2-to-3'
import { alphaProfileMigration20To21 } from './alpha-profile-migration-20-to-21'
import { alphaProfileMigration3To4 } from './alpha-profile-migration-3-to-4'
import { alphaProfileMigration4To5 } from './alpha-profile-migration-4-to-5'
import { alphaProfileMigration5To6 } from './alpha-profile-migration-5-to-6'
Expand Down Expand Up @@ -43,4 +44,6 @@ export const ALPHA_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
18: alphaProfileMigration18To19,
// ^^^ release 1.0.3 ^^^
19: alphaProfileMigration19To20,
// ^^^ release 1.0.4 ^^^
20: alphaProfileMigration20To21,
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { prodProfileMigration6To7 } from './prod-profile-migration-6-to-7'
import { prodProfileMigration7To8 } from './prod-profile-migration-7-to-8'
import { prodProfileMigration4To5 } from './prod-profile-migration-4-to-5'
import { prodProfileMigration8To9 } from './prod-profile-migration-8-to-9'
import { addDefaultIscChainsToIotaProfiles } from '../actions/addDefaultIscChainsToIotaProfiles'

export async function prodProfileMigration9To10(existingProfile: unknown): Promise<void> {
const profile = existingProfile as IPersistedProfile
Expand Down Expand Up @@ -37,5 +38,7 @@ export async function prodProfileMigration9To10(existingProfile: unknown): Promi
// prodProfileMigration8To9 recovery
await prodProfileMigration8To9(profile)

addDefaultIscChainsToIotaProfiles(profile)

return Promise.resolve()
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export const PROD_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
6: prodProfileMigration6To7,
7: prodProfileMigration7To8,
// ^^^ release 1.0.2 ^^^
8: prodProfileMigration8To9, // Migration was removed and replaced with 10To11 after 9To10
8: prodProfileMigration8To9,
// ^^^ release 1.0.3 ^^^
9: prodProfileMigration9To10, // rechecking some previous migrations due to a bug during migrations
10: prodProfileMigration10To11,
// ^^^ release 1.0.4 ^^^
}
1 change: 1 addition & 0 deletions packages/shared/src/lib/features/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './isFeatureEnabled'
export * from './isFeatureGeoFenced'
21 changes: 21 additions & 0 deletions packages/shared/src/lib/features/utils/isFeatureGeoFenced.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { countryCode } from '@auxiliary/country/stores'
import { appParameters } from '@core/app/stores'
import { get } from 'svelte/store'

export function isFeatureNotGeoFenced(featureString: string): boolean {
const currentCountryCode = get(countryCode)
const featurePathToCheck = featureString.split('.')
const geoFence = get(appParameters)?.geoFence
let previousFeatures = geoFence
for (let i = 0; i < featurePathToCheck.length; i++) {
const currentFeature = previousFeatures?.[featurePathToCheck[i]]
if (!currentFeature) {
return true
}
if (i === featurePathToCheck.length - 1) {
return !currentFeature?.some((blockedCountry) => blockedCountry === currentCountryCode)
}
previousFeatures = currentFeature
}
return true
}

0 comments on commit 32f3b47

Please sign in to comment.