Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staking interface updates #302

Open
wants to merge 6 commits into
base: tokens-threshold-lib
Choose a base branch
from

Conversation

r-czajkowski
Copy link
Collaborator

@r-czajkowski r-czajkowski commented Nov 10, 2022

Depends on: #300

This PR moves the contract integration part from hooks to the Threshold-ts library. Thanks to this layer we can separate work between UI and contract integration. Also, it helps to unit test created services and move the "business logic" from the React hooks.

Main changes

Staking in Threshold-ts lib

  1. Adds interface and implementations of the PRE app. Currently, the PRE contract doesn't implement the IApplicaiton interface and doesn't require authorization- in that case, the PRE app doesn't implement a common interfaceIApplication in typescript library. Probably in the future we should keep one common interface that every app should implement.
  2. Updates unit tests.

React

  1. Moves fetching owner stakes to listener middleware- we want to fetch the owner stakes only once so the best place for
    fetching this data is a one-shot listener and an effect callback will be run on walletConnected action.
  2. Updates the staking state in redux store- gets rid of the preConfig field- the PRE is a separate staking app so we should store it in the staking-application slice.
  3. Moves the PRE-related data to a staking-application slice- stores the PRE data per staking provider in the same way as for random-beacon and ecdsa apps. Fetches this data in listener middleware.
  4. Removes unnecessary hooks for fetching data.

We want to fetch the owner stakes only once so the best place for
fetching this data is one-shot listener effect.
We should register listener in different file than the one in which it
is defined otherwise we may run into an issue with webpack import
orddering. Here we create a common function that should register all
listeners and we call this fn after creating a store and after resetting
the store.
Use the `Stake` type from the threshold ts lib- this removes the
`preConfig` filed from the `StakeData` type. The PRE is a staking app so
should be stored in a dedicated slice(rewards). We are going to add the
PRE app to the rewards slice in a follow-up work.
The PRE is a seprate app so should be stored in the `staking-apps` slice
not as a part of the stake data.
@github-actions
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant