Skip to content

Commit

Permalink
feat: update DEFAULT_SYNC_OPTIONS and remove debris
Browse files Browse the repository at this point in the history
  • Loading branch information
evavirseda committed Mar 20, 2024
1 parent 1b5576d commit 0f807c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
10 changes: 4 additions & 6 deletions packages/shared/lib/core/profile/actions/active-profile/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
isStrongholdUnlocked,
refreshWalletAssetsForActiveProfile,
setSelectedWallet,
setStrongholdPasswordClearInterval,
startBackgroundSync,
} from '@core/wallet/actions'
import { get } from 'svelte/store'
import { CHECK_PREVIOUS_WALLETS_ARE_DESTROYED_TIMEOUT } from '../../constants'
Expand All @@ -34,7 +36,7 @@ import { logout } from './logout'
import { subscribeToWalletApiEventsForActiveProfile } from './subscribeToWalletApiEventsForActiveProfile'
import { checkAndUpdateActiveProfileNetwork } from './checkAndUpdateActiveProfileNetwork'
import { checkAndRemoveProfilePicture } from './checkAndRemoveProfilePicture'
import { setStrongholdPasswordClearInterval, startBackgroundSync } from '@core/wallet/actions'
import { DEFAULT_SYNC_OPTIONS } from '@core/wallet/constants'

export async function login(loginOptions?: ILoginOptions): Promise<void> {
const loginRouter = get(routerManager).getRouterForAppContext(AppContext.Login)
Expand Down Expand Up @@ -94,11 +96,7 @@ export async function login(loginOptions?: ILoginOptions): Promise<void> {
incrementLoginProgress()
subscribeToWalletApiEventsForActiveProfile()

await startBackgroundSync({
syncIncomingTransactions: true,
syncImplicitAccounts: true,
account: { nftOutputs: true },
})
await startBackgroundSync(DEFAULT_SYNC_OPTIONS)

// Step 8: finish login
incrementLoginProgress()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
preprocessGroupedOutputs,
syncBalance,
validateWalletApiEvent,
DEFAULT_SYNC_OPTIONS,
} from '@core/wallet'
import {
AccountAddress,
Expand Down Expand Up @@ -47,20 +46,10 @@ export async function handleNewOutputEventInternal(walletId: string, payload: Ne

const output = outputData.output
const isNftOutput = output.type === OutputType.Nft
let _isDelegationOutput = isDelegationOutput(outputData)
const _isDelegationOutput = isDelegationOutput(outputData)

const address = outputData.address ? AddressConverter.addressToBech32(outputData.address) : undefined

// TODO: Improve this logic when the delegation output is received -> https://github.com/iotaledger/firefly/issues/8187
if (wallet?.hasDelegationTransactionInProgress) {
const prevDelegationOutputs = wallet.walletUnspentOutputs?.filter(isDelegationOutput) || []
await wallet.sync(DEFAULT_SYNC_OPTIONS)
const postDelegationOutputs = (await wallet.unspentOutputs())?.filter(isDelegationOutput) || []
if (prevDelegationOutputs.length < postDelegationOutputs.length) {
_isDelegationOutput = true
}
}

// The basic outputs of the faucet dont have an address
const isBasicOutput = output.type === OutputType.Basic
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export const DEFAULT_SYNC_OPTIONS: SyncOptions = {
},
syncIncomingTransactions: true,
syncNativeTokenFoundries: true,
syncImplicitAccounts: true,
}

0 comments on commit 0f807c4

Please sign in to comment.