Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add implicit account creation wizard and router #7877

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e7fb493
feat: add account to routes
evavirseda Dec 22, 2023
f59e885
feat: add to analytics featureflag
evavirseda Dec 22, 2023
d8318ab
feat: add account view and multistep
evavirseda Dec 26, 2023
ba6be6b
style: refinements
evavirseda Dec 26, 2023
9de9319
feat: rename files and add locale
evavirseda Dec 26, 2023
0705215
fix: update naming
evavirseda Jan 4, 2024
30a4b81
Merge branch 'feat/add-implicit-account-router' into feat/add-implici…
evavirseda Jan 4, 2024
af504e3
feat: update naming and improve code
evavirseda Jan 4, 2024
3390dc2
fix import
evavirseda Jan 4, 2024
ab1919a
Merge branch 'feat/add-implicit-account-router' into feat/add-implici…
evavirseda Jan 4, 2024
bf15770
fix: remove accountImplicit route and add to wallet tab
evavirseda Jan 10, 2024
2d7273d
fix: improve naming
evavirseda Jan 10, 2024
45a5ce6
Merge branch 'feat/add-implicit-account-router' into feat/add-implici…
evavirseda Jan 10, 2024
784014c
Update packages/desktop/views/dashboard/wallet/Wallet.svelte
begonaalvarezd Jan 10, 2024
3f0ab3c
Update packages/desktop/views/dashboard/wallet/Wallet.svelte
begonaalvarezd Jan 10, 2024
1347de2
Merge branch 'feat/add-implicit-account-router' into feat/add-implici…
evavirseda Jan 10, 2024
669d0af
Merge branch 'develop-iota2.0' into feat/add-implicit-account-creatio…
evavirseda Jan 11, 2024
1970e9e
fix: add router
evavirseda Jan 11, 2024
057c9f5
minor fixes
evavirseda Jan 11, 2024
e0e09c8
ix: add missing dots
evavirseda Jan 11, 2024
1016b96
fix: remove unnecessary function
evavirseda Jan 11, 2024
3171553
fix: rename files
evavirseda Jan 11, 2024
f4a90f5
fix: move if/else and key block
evavirseda Jan 11, 2024
9272310
fix: reset after finish
evavirseda Jan 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/desktop/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import { downloadNextNftInQueue, nftDownloadQueue } from '@core/nfts'
import features from '@features/features'
import { OnboardingRouterView } from '@views/onboarding'
import AccountRouter from '@views/account/AccountRouter.svelte'

appStage.set(AppStage[process.env.STAGE.toUpperCase()] ?? AppStage.ALPHA)

Expand Down Expand Up @@ -194,6 +195,8 @@
<LoginRouter />
{:else if $appRoute === AppRoute.Onboarding}
<OnboardingRouterView />
{:else if $appRoute === AppRoute.Account}
<AccountRouter />
{/if}
{#if settings}
<Settings handleClose={onCloseSettingsClick} />
Expand Down
3 changes: 3 additions & 0 deletions packages/desktop/features/analytics.features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const analyticsFeatures: IAnalyticsFeatures = {
strongholdMigration: {
enabled: true,
},
accountRoute: {
enabled: true,
},
}

export default analyticsFeatures
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface IAnalyticsFeatures extends IFeatureFlag {
loginRoute: IFeatureFlag
dashboardRoute: IFeatureFlag
strongholdMigration: IFeatureFlag
accountRoute: IFeatureFlag
}
3 changes: 3 additions & 0 deletions packages/desktop/lib/routers/actions/initialiseRouters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
AccountRouter,
accountRouter,
appRouter,
AppRouter,
collectiblesRouter,
Expand Down Expand Up @@ -30,6 +32,7 @@ export function initialiseOnboardingRouters(): void {
function initialiseBaseRouters(): void {
appRouter.set(new AppRouter())
dashboardRouter.set(new DashboardRouter())
accountRouter.set(new AccountRouter())
settingsRouter.set(new SettingsRouter())
collectiblesRouter.set(new CollectiblesRouter())
governanceRouter.set(new GovernanceRouter())
Expand Down
4 changes: 3 additions & 1 deletion packages/desktop/lib/routers/utils/getRouterForAppContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { get } from 'svelte/store'

import { AppContext } from '@core/app/enums'
import { IRouter } from '@core/router/interfaces'
import { dashboardRouter, settingsRouter } from '@core/router/routers'
import { accountRouter, dashboardRouter, settingsRouter } from '@core/router/routers'
import { loginRouter } from '@core/router/subrouters'
import { onboardingRouter } from '@views/onboarding'

Expand All @@ -16,6 +16,8 @@ export function getRouterForAppContext(context: AppContext): IRouter {
return get(onboardingRouter)
case AppContext.Settings:
return get(settingsRouter)
case AppContext.Account:
return get(accountRouter)
default:
return undefined
}
Expand Down
16 changes: 16 additions & 0 deletions packages/desktop/views/account/AccountRouter.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script lang="ts">
import { Platform } from '@core/app'
import { AccountRoute, accountRoute } from '@core/router'
import features from '@features/features'
import { Transition } from 'shared/components'
import { MainView } from './activate'

$: if (features.analytics.accountRoute.enabled && $accountRoute)
Platform.trackEvent('account-route', { route: $accountRoute })
</script>

{#if $accountRoute === AccountRoute.Activate}
<Transition>
<MainView />
</Transition>
{/if}
69 changes: 69 additions & 0 deletions packages/desktop/views/account/activate/MainView.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<script lang="ts">
import { Button, FontWeight, Text, TextType } from 'shared/components'
import { MultiStep } from '../multi-step'
import { localize } from '@core/i18n'

interface IStep {
title: string
description: string
image: string
}

const MAIN_VIEW_STEPS: IStep[] = [
{
title: localize('views.implicit-account.steps.step1.title'),
description: localize('views.implicit-account.steps.step1.body'),
image: 'assets/illustrations/implicit-account/show-one-time-address.svg',
},
{
title: localize('views.implicit-account.steps.step2.title'),
description: localize('views.implicit-account.steps.step2.body'),
image: 'assets/illustrations/implicit-account/generate-mana.svg',
},
{
title: localize('views.implicit-account.steps.step3.title'),
description: localize('views.implicit-account.steps.step3.body'),
image: 'assets/illustrations/implicit-account/sign-transaction.svg',
},
]
cpl121 marked this conversation as resolved.
Show resolved Hide resolved

let startProccess = false

function startMultiStepProccess(): void {
startProccess = true
}
</script>

<section class="flex flex-col w-full h-full pt-5 px-60 pb-12 items-center justify-between">
<box-content class="flex flex-col w-full h-full pt-9 px-8 pb-12 items-center justify-between rounded-2xl">
<Text type={TextType.h2}>{localize('views.implicit-account.title')}</Text>
{#if !startProccess}
<steps-wrapper class="flex space-x-4">
{#each MAIN_VIEW_STEPS as step}
<step-content class="flex flex-col items-center space-y-8">
<img src={step.image} alt={step.title} />
<div class="flex flex-col text-center px-4 space-y-2">
<Text
type={TextType.h5}
fontSize="15"
color="blue-700"
darkColor="blue-700"
fontWeight={FontWeight.semibold}>{step.title}</Text
>
<Text type={TextType.h3} fontWeight={FontWeight.semibold}>{step.description}</Text>
</div>
</step-content>
{/each}
</steps-wrapper>
<Button onClick={startMultiStepProccess}>{localize('views.implicit-account.action')}</Button>
{:else}
<MultiStep />
{/if}
</box-content>
</section>

<style lang="scss">
box-content {
box-shadow: 0px 1px 4px 0px rgba(23, 27, 37, 0.04);
}
</style>
1 change: 1 addition & 0 deletions packages/desktop/views/account/activate/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as MainView } from './MainView.svelte'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>GenerateMana</h1>
32 changes: 32 additions & 0 deletions packages/desktop/views/account/multi-step/MultiStep.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script lang="ts">
import { AccountState } from '@contexts/account'

const IMPLICIT_ACCOUNT_STEPS: AccountState[] = Object.values(AccountState)

let activeState: AccountState | null = null
let onNext: () => Promise<boolean>
let currentStep: number = 0
let activeComponent

async function loadComponent() {
activeState = IMPLICIT_ACCOUNT_STEPS[currentStep]
const component = await import(`./${activeState}.svelte`)
activeComponent = component.default
}

async function handleNext() {
currentStep += 1
await loadComponent()
}

$: loadComponent()
</script>

<section>
{#if activeComponent}
<svelte:component this={activeComponent} {activeState} {onNext} />
{#if currentStep < IMPLICIT_ACCOUNT_STEPS.length - 1}
<button on:click={handleNext}>Next</button>
{/if}
{/if}
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>ShowOneTimeAddress</h1>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>SignTransaction</h1>
4 changes: 4 additions & 0 deletions packages/desktop/views/account/multi-step/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as ShowOneTimeAddress } from './ShowOneTimeAddress.svelte'
export { default as GenerateMana } from './GenerateMana.svelte'
export { default as SignTransaction } from './SignTransaction.svelte'
export { default as MultiStep } from './MultiStep.svelte'
cpl121 marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum AccountState {
cpl121 marked this conversation as resolved.
Show resolved Hide resolved
SHOW_ONE_TIME_ADDRESS = 'ShowOneTimeAddress',
GENERATE_MANA = 'GenerateMana',
SIGN_TRANSACTION = 'SignTransaction',
}
1 change: 1 addition & 0 deletions packages/shared/lib/contexts/account/enums/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './account-state.enum'
1 change: 1 addition & 0 deletions packages/shared/lib/contexts/account/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './enums'
1 change: 1 addition & 0 deletions packages/shared/lib/core/app/enums/app-context.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export enum AppContext {
Dashboard = 'dashboard',
Settings = 'settings',
Onboarding = 'wallet',
Account = 'account',
}
3 changes: 3 additions & 0 deletions packages/shared/lib/core/router/enums/account-route.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum AccountRoute {
Activate = 'activate',
}
1 change: 1 addition & 0 deletions packages/shared/lib/core/router/enums/app-route.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum AppRoute {
Dashboard = 'dashboard',
Login = 'login',
Onboarding = 'onboarding',
Account = 'account',
}
1 change: 1 addition & 0 deletions packages/shared/lib/core/router/enums/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './onboarding'
export * from './settings'

export * from './account-route.enum'
export * from './app-route.enum'
export * from './collectibles-route.enum'
export * from './dashboard-route.enum'
Expand Down
12 changes: 12 additions & 0 deletions packages/shared/lib/core/router/routers/account-router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { writable } from 'svelte/store'
import { Router } from '../classes'
import { AccountRoute } from '../enums'

export const accountRouter = writable<AccountRouter>(null)
export const accountRoute = writable<AccountRoute>(null)

export class AccountRouter extends Router<AccountRoute> {
constructor() {
super(AccountRoute.Activate, accountRoute)
}
}
11 changes: 10 additions & 1 deletion packages/shared/lib/core/router/routers/app-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { loginRoute } from '../subrouters'
export const appRoute = writable<AppRoute>(null)
export const appRouter = writable<AppRouter>(null)

// TODO: Replace this hardcoded variable when we have a proper way to check if the user has an implicit account
const hasImplicitAccount = false

export class AppRouter extends Router<AppRoute> {
constructor() {
super(AppRoute.Onboarding, appRoute)
Expand All @@ -35,11 +38,17 @@ export class AppRouter extends Router<AppRoute> {
case AppRoute.Login: {
if (params.shouldAddProfile) {
nextRoute = AppRoute.Onboarding
} else {
} else if (hasImplicitAccount) {
nextRoute = AppRoute.Dashboard
} else {
nextRoute = AppRoute.Account
}
break
}
case AppRoute.Account: {
nextRoute = AppRoute.Dashboard
break
}
case AppRoute.Dashboard: {
if (params.reset) {
nextRoute = AppRoute.Login
Expand Down
1 change: 1 addition & 0 deletions packages/shared/lib/core/router/routers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './account-router'
export * from './app-router'
export * from './collectibles-router'
export * from './dashboard-router'
Expand Down
18 changes: 18 additions & 0 deletions packages/shared/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,24 @@
"title": "Vesting of tokens",
"body": "From the tokens users received through an IOTA token airdrop, 10% are being available to users immediately at the genesis of the IOTA Stardust network. The rest is gradually unlocked over the course of two years in equal proportion happening every two weeks."
}
},
"implicit-account":{
cpl121 marked this conversation as resolved.
Show resolved Hide resolved
"title": "Activate Account",
"steps" : {
"step1": {
evavirseda marked this conversation as resolved.
Show resolved Hide resolved
"title": "Step 1",
"body": "One-time deposit"
},
"step2": {
"title": "Step 2",
"body": "Fund confirmation"
},
"step3": {
"title": "Step 3",
"body": "Account creation"
}
},
"action": "Start"
}
},
"popups": {
Expand Down
Loading