Skip to content

Commit 5202f8d

Browse files
committed
Standalone remove and add recovery methods
1 parent 6809891 commit 5202f8d

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

packages/wallet/wdk/src/sequence/recovery.ts

+25
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Address, Hex, Provider, RpcTransport } from 'ox'
44
import { RecoverySigner } from './types/signer.js'
55
import { Envelope } from '@0xsequence/wallet-core'
66
import { QueuedRecoveryPayload } from './types/recovery.js'
7+
import { Actions } from './types/index.js'
78

89
export class Recovery {
910
constructor(private readonly shared: Shared) {}
@@ -128,6 +129,30 @@ export class Recovery {
128129
})
129130
}
130131

132+
async addRecoverySigner(address: Address.Address) {
133+
const { modules } = await this.shared.modules.wallets.getConfigurationParts(address)
134+
await this.addRecoverySignerToModules(modules, address)
135+
return this.shared.modules.wallets.requestConfigurationUpdate(
136+
address,
137+
{
138+
modules,
139+
},
140+
Actions.AddRecoverySigner,
141+
'wallet-webapp',
142+
)
143+
}
144+
145+
async removeRecoverySigner(address: Address.Address) {
146+
const { modules } = await this.shared.modules.wallets.getConfigurationParts(address)
147+
await this.removeRecoverySignerFromModules(modules, address)
148+
return this.shared.modules.wallets.requestConfigurationUpdate(
149+
address,
150+
{ modules },
151+
Actions.RemoveRecoverySigner,
152+
'wallet-webapp',
153+
)
154+
}
155+
131156
async getRecoverySigners(address: Address.Address): Promise<RecoverySigner[] | undefined> {
132157
const { raw } = await this.shared.modules.wallets.getConfiguration({ wallet: address })
133158
const recoveryLeaf = raw.modules.find((m) => m.address === this.shared.sequence.extensions.recovery)

packages/wallet/wdk/src/sequence/types/signature-request.ts

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export type ActionToPayload = {
99
[Actions.SendTransaction]: Payload.Calls
1010
[Actions.SessionUpdate]: Payload.ConfigUpdate
1111
[Actions.Recovery]: Payload.Recovery<Payload.Calls>
12+
[Actions.AddRecoverySigner]: Payload.ConfigUpdate
13+
[Actions.RemoveRecoverySigner]: Payload.ConfigUpdate
1214
}
1315

1416
export const Actions = {
@@ -17,6 +19,8 @@ export const Actions = {
1719
SendTransaction: 'send-transaction',
1820
SessionUpdate: 'session-update',
1921
Recovery: 'recovery',
22+
AddRecoverySigner: 'add-recovery-signer',
23+
RemoveRecoverySigner: 'remove-recovery-signer',
2024
} as const
2125

2226
export type Action = (typeof Actions)[keyof typeof Actions]

packages/wallet/wdk/src/session/session-controller.ts

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export class SessionController {
104104
private async prepareUpdateConfiguration(
105105
topology: SessionConfig.SessionsTopology,
106106
): Promise<Envelope.Envelope<Payload.ConfigUpdate>> {
107+
// TODO: Reuse `requestConfigurationUpdate` and `getConfigurationParts` from wallets module
107108
// Create a new manager with the new topology
108109

109110
// Store the new configuration

0 commit comments

Comments
 (0)