Skip to content

Commit f9c5cb0

Browse files
author
cpl121
committed
refactor: complete onboarding
1 parent 72362bd commit f9c5cb0

File tree

4 files changed

+9
-25
lines changed

4 files changed

+9
-25
lines changed
Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { activeProfile, activeWallets, addWalletPersistedDataToActiveProfile, createWallet, login } from '@core/profile'
1+
import { IWallet, activeProfile, activeWallets, addWalletPersistedDataToActiveProfile, createWallet, login } from '@core/profile'
22
import { get } from 'svelte/store'
33
import { OnboardingType } from '../enums'
44
import { addWalletPersistedDataToOnboardingProfile, onboardingProfile } from '../stores'
@@ -16,50 +16,35 @@ export async function completeOnboardingProcess(): Promise<void> {
1616
createNewProfileFromOnboardingProfile()
1717
}
1818

19-
console.log("post createNewProfileFromOnboardingProfile", get(activeProfile))
20-
2119
const onboardingType = get(onboardingProfile)?.onboardingType
2220
const shouldRecoverAccounts = onboardingType === OnboardingType.Restore || onboardingType === OnboardingType.Claim
2321
showBalanceOverviewPopup.set(shouldRecoverAccounts)
2422

25-
console.log("pre createOnboardingWallet -----")
26-
2723
await createOnboardingWallet()
28-
29-
console.log("post createOnboardingWallet and pre login");
30-
31-
3224
void login({ isFromOnboardingFlow: true, shouldRecoverAccounts })
3325

3426
onboardingProfile.set(undefined)
3527
}
3628

37-
export async function createOnboardingWallet(name?: string, color?: string): Promise<IWalletState> {
29+
export async function createOnboardingWallet(name?: string, color?: string): Promise<IWallet> {
3830
// 1. Get the wallet name
3931
const walletName = name || `${localize('general.account')} ${(get(activeWallets)?.length ?? 0) + 1}`;
4032

41-
console.log("walletName", walletName)
42-
4333
// 2. Create the wallet instance
4434
const wallet = await createWallet()
4535

46-
console.log("wallet", wallet)
47-
4836
// 3. Sync the wallet with the Node
4937
// TODO(2.0): test & fix sync when we have iota2.0 nodes
50-
//await account.sync(DEFAULT_SYNC_OPTIONS)
51-
38+
//await wallet.sync(DEFAULT_SYNC_OPTIONS)
5239
// 4. Create a wrapper over the wallet instance and the persisted data
53-
const [walletState, accountPersistedData] = await buildWalletStateAndPersistedData(wallet, walletName, color)
54-
55-
console.log("walletState", walletState, accountPersistedData)
40+
// const [walletState, accountPersistedData] = await buildWalletStateAndPersistedData(wallet, walletName, color)
5641

5742
// TODO(2.0) Fix
5843
// addAccountToActiveAccounts(walletState)
59-
addWalletPersistedDataToOnboardingProfile(walletState.id, accountPersistedData)
44+
// addWalletPersistedDataToOnboardingProfile(walletState.id, accountPersistedData)
6045
// TODO(2.0) Fix
6146
// addEmptyAccountActivitiesToAllAccountActivities(walletState.id)
6247

6348

64-
return walletState
49+
return wallet
6550
}

packages/shared/lib/contexts/onboarding/stores/onboarding-profile.store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IOnboardingProfile, IShimmerClaimingWallet } from '../interfaces'
66
import { IBaseToken, IPersistedWalletData } from '@core/wallet/interfaces'
77
import { IPersistedNetwork } from '@core/network'
88

9-
export const onboardingProfile = writable<IOnboardingProfile | null>(null)
9+
export const onboardingProfile = writable<IOnboardingProfile | null | undefined>(null)
1010

1111
export const isOnboardingLedgerProfile: Readable<boolean> = derived(onboardingProfile, ($onboardingProfile) =>{
1212
console.log("Changed?")

packages/shared/lib/core/wallet/actions/buildWalletState.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export async function buildWalletState(
3434
let depositAddress = ''
3535
let votingPower = ''
3636
try {
37-
await wallet.sync()
3837
balances = await wallet.getBalance()
3938
depositAddress = await getDepositAddress(wallet)
4039
votingPower = balances.baseCoin.votingPower

packages/shared/lib/core/wallet/actions/getAddressesWithOutputs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { IWallet } from '@core/profile/interfaces'
33
import { Address } from '@iota/sdk/out/types'
44

55
// TODO(2.0) Fix all usages
6-
export async function getAddressesWithOutputs(account: IWallet | IWalletState): Promise<AddressWithOutputs[]> {
6+
export async function getAddressesWithOutputs(wallet: IWallet | IWalletState): Promise<AddressWithOutputs[]> {
77
let addressesWithOutputs: AddressWithOutputs[] = []
88
const addresses: Address[] = [] // await account.accounts
9-
const outputs = await account.outputs()
9+
const outputs = await wallet.outputs()
1010

1111
const outputMapped: AddressWithOutputs[] = outputs.reduce((acc: AddressWithOutputs[], output) => {
1212
const address = getBech32AddressFromAddressTypes(output.address)

0 commit comments

Comments
 (0)