Skip to content

Commit e595935

Browse files
committed
fix: ensure to limit deleting of old network assets to tokens that we're resolving
1 parent 809c009 commit e595935

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libs/api/network-asset/data-access/src/lib/api-network-asset-sync.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ export class ApiNetworkAssetSyncService {
209209
this.logger.error(`[${cluster}] syncIdentity: Error syncing assets for ${owner} on ${cluster}: ${error}`)
210210
throw error
211211
}
212-
const assetIds = assets.map((a) => a.account)
213212

214213
this.logger.verbose(`[${cluster}] syncIdentity: Resolved ${assets.length} assets for ${owner} on ${cluster}`)
215214
if (!assets.length) {
@@ -219,10 +218,13 @@ export class ApiNetworkAssetSyncService {
219218
// Upsert the assets
220219
await this.upsertAssets({ cluster, assets, linkIdentity: true })
221220

222-
// Remove any assets that are not in the list
221+
// Remove any assets that are in these groups and did not get resolved.
222+
const groups = tokens.map((t) => t.account)
223+
const assetIds = assets.map((a) => a.account)
223224
const removedIds = await this.core.data.networkAsset.deleteMany({
224225
where: {
225226
owner,
227+
group: { in: groups },
226228
NOT: { account: { in: assetIds } },
227229
},
228230
})

0 commit comments

Comments
 (0)