@@ -1198,6 +1198,7 @@ export class Wallets implements WalletsInterface {
11981198 this . shared . databases . manager . del ( wallet ) ,
11991199 this . shared . modules . devices . remove ( walletEntry . device ) ,
12001200 ] )
1201+ await this . _cleanupWalletData ( wallet )
12011202 return undefined as any
12021203 }
12031204
@@ -1251,6 +1252,31 @@ export class Wallets implements WalletsInterface {
12511252 await this . completeConfigurationUpdate ( requestId )
12521253 await this . shared . databases . manager . del ( request . wallet )
12531254 await this . shared . modules . devices . remove ( walletEntry . device )
1255+ await this . _cleanupWalletData ( request . wallet )
1256+ }
1257+
1258+ private async _cleanupWalletData ( wallet : Address . Address ) : Promise < void > {
1259+ const [ sigs , txns , msgs , recovery ] = await Promise . all ( [
1260+ this . shared . databases . signatures . list ( ) ,
1261+ this . shared . databases . transactions . list ( ) ,
1262+ this . shared . databases . messages . list ( ) ,
1263+ this . shared . databases . recovery . list ( ) ,
1264+ ] )
1265+
1266+ await Promise . all ( [
1267+ ...sigs . filter ( ( s ) => Address . isEqual ( s . wallet , wallet ) ) . map ( ( s ) => this . shared . databases . signatures . del ( s . id ) ) ,
1268+ ...txns . filter ( ( t ) => Address . isEqual ( t . wallet , wallet ) ) . map ( ( t ) => this . shared . databases . transactions . del ( t . id ) ) ,
1269+ ...msgs . filter ( ( m ) => Address . isEqual ( m . wallet , wallet ) ) . map ( ( m ) => this . shared . databases . messages . del ( m . id ) ) ,
1270+ ...recovery . filter ( ( r ) => Address . isEqual ( r . wallet , wallet ) ) . map ( ( r ) => this . shared . databases . recovery . del ( r . id ) ) ,
1271+ ] )
1272+
1273+ try {
1274+ const { loginTopology } = await this . getConfigurationParts ( wallet )
1275+ const loginSigners = Config . getSigners ( loginTopology )
1276+ await Promise . all ( loginSigners . signers . map ( ( s ) => this . shared . databases . authKeys . delBySigner ( s . toString ( ) ) ) )
1277+ } catch {
1278+ // Don't fail logout if config lookup fails (e.g. offline)
1279+ }
12541280 }
12551281
12561282 async getConfiguration ( wallet : Address . Address ) {
0 commit comments