Skip to content

Commit 72362bd

Browse files
author
cpl121
committed
fix: improve logs and try to sync balances for wallet WIP
1 parent a470021 commit 72362bd

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

packages/shared/lib/contexts/onboarding/actions/completeOnboardingProcess.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,23 @@ export async function completeOnboardingProcess(): Promise<void> {
1111
// if we already have an active profile
1212
// it means we are trying to load again after an error
1313
// and we don't need to add it again
14-
console.log(get(activeProfile), get(onboardingProfile))
14+
console.log("get(activeProfile), get(onboardingProfile)", get(activeProfile), get(onboardingProfile))
1515
if (!get(activeProfile)?.id) {
1616
createNewProfileFromOnboardingProfile()
1717
}
1818

19-
console.log(get(activeProfile))
19+
console.log("post createNewProfileFromOnboardingProfile", get(activeProfile))
2020

2121
const onboardingType = get(onboardingProfile)?.onboardingType
2222
const shouldRecoverAccounts = onboardingType === OnboardingType.Restore || onboardingType === OnboardingType.Claim
2323
showBalanceOverviewPopup.set(shouldRecoverAccounts)
2424

25+
console.log("pre createOnboardingWallet -----")
2526

2627
await createOnboardingWallet()
28+
29+
console.log("post createOnboardingWallet and pre login");
30+
2731

2832
void login({ isFromOnboardingFlow: true, shouldRecoverAccounts })
2933

packages/shared/lib/core/profile/actions/createWallet.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { get } from 'svelte/store'
44
import { IWallet } from '../interfaces'
55
import { activeProfile as activeProfileStore } from '../stores'
66
import { getSecretManagerFromProfileType, getStorageDirectoryOfProfile } from '../utils'
7+
import { WalletOptions } from '@iota/sdk'
78

89
// TODO(2.0): Fix and finish this method
910
/* - __storage__/
@@ -15,24 +16,22 @@ import { getSecretManagerFromProfileType, getStorageDirectoryOfProfile } from '.
1516
export async function createWallet(activeProfile = get(activeProfileStore)): Promise<IWallet> {
1617
const id = generateRandomId()
1718
const storagePath = await getStorageDirectoryOfProfile(id)
18-
const snapshotPath = ''
19+
// const snapshotPath = ''
1920

20-
const walletOptions = {
21+
const walletOptions: WalletOptions = {
2122
clientOptions: activeProfile.clientOptions,
2223
secretManager: getSecretManagerFromProfileType(activeProfile.type, storagePath),
2324
bipPath: {
24-
coinType: activeProfile.network.coinType
25-
}
25+
coinType: activeProfile.network.coinType,
26+
account: 0,
27+
addressIndex: 0
28+
},
29+
coinType: activeProfile.network.coinType
2630
}
2731
console.log("walletOptions", walletOptions);
28-
2932
const wallet = await api.createWallet(id, {
3033
...walletOptions,
3134
storagePath,
3235
})
33-
34-
console.log("wallet", wallet);
35-
36-
3736
return wallet
3837
}

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

+3
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,20 @@ export async function buildWalletState(
2121
basic: BigInt(0),
2222
foundry: BigInt(0),
2323
nft: BigInt(0),
24+
delegation: BigInt(0)
2425
},
2526
nativeTokens: [],
2627
nfts: [],
2728
foundries: [],
2829
potentiallyLockedOutputs: {},
2930
accounts: [],
31+
delegations: []
3032
}
3133

3234
let depositAddress = ''
3335
let votingPower = ''
3436
try {
37+
await wallet.sync()
3538
balances = await wallet.getBalance()
3639
depositAddress = await getDepositAddress(wallet)
3740
votingPower = balances.baseCoin.votingPower

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

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export async function buildWalletStateAndPersistedData(
1818
shouldRevote: false,
1919
walletOptions: {}
2020
}
21+
console.log("persistedWalletData", persistedWalletData);
22+
2123
const accountState = await buildWalletState(wallet, persistedWalletData)
24+
console.log("accountState", accountState);
2225
return [accountState, persistedWalletData]
2326
}

0 commit comments

Comments
 (0)