LedgerHQ / ledger-fresh-management

This is where product topics are discussed for Ledger Fresh
Apache License 2.0
14 stars 2 forks source link

[Watcher/Notification Center] - Listen challenge period events and call the notification module #47

Open qd-qd opened 1 year ago

qd-qd commented 1 year ago

Header

Name of the task: Listen Challenge Period events

Name of the module: Watcher

Difficulty: 3

Waiting for: #37 #39 #46

Body

Short description

Listen to challenge period events and react to them in order to inform the signers as fast as possible that a new challenge period started.

Full description

Some interactions with the wallet can have a significant impact on security or access to the wallet (like adding or removing a plugin for example). That's why we decided to apply a challenge period to all critical interactions issued by a wallet signer.

A challenge period is simply a delay we apply to sensitive actions. When a user tries to do something we flagged sensitive, we delay the execution of the transaction for a specific amount of time. Thanks to that, signers associated with the wallet will have the opportunity to cancel execution they don't want.

A challenge period will not work properly if we don't inform the signers as fast as possible. This is the goal of this task, create the connection between the watcher and the notification module.

In this task, you will have to extend the work done in #46. Here's what must be done:

Here's one example of the event you will have to include in the watching service for all the smart contracts deployed by our deployer:

// the `issuer` represents the signer who started the challenge period
// the `reason` is a string that tries to explain the context of the challenge period 
// the `end_timestamp` informs when the challenge period ends (calculated by summing the current timestamp with the duration of the challenge period)
@event
func challenge_period_start(
    wallet_address: felt, issuer: felt, reason: felt, end_timestamp: felt
) {}

// the `issuer` represents the signer who ended the challenge period
@event
func challenge_period_end(
    wallet_address: felt, issuer: felt
) {}

⚠️ The signature of these events are not definitive. Please double-check with the team before working on the implementation of this task.

Now that the challenge period events are tracked, we have to react to them properly and as fast as possible. In order to know where to notify the user, we have to interact with the database created in #37. The database created in #37 holds a mapping of wallet_address->communication_channels. Here's what must be done regarding this part of this task:

ℹ️ To validate this task, passing the reason in the events as the message in the expected payload of the API is enough. We will see in the future how to make the notification more understandable.

You have to manage all relevant HTTP errors properly. Everything must be tested, prettied, eslinted and the README of the repository should describe the API. You are free to use the ORM you want (under the condition it is still maintained and the product is known in the OSS ecosystem).

Additionals ressources

github-actions[bot] commented 1 year ago

Task monitoring 📝


This is an automatic post that is intended to facilitate the follow-up of the project. This post is meant to be edited throughout the life of the project.