Skip to content

Threshold lib updates #299

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

Merged
merged 5 commits into from
Nov 18, 2022
Merged

Threshold lib updates #299

merged 5 commits into from
Nov 18, 2022

Conversation

r-czajkowski
Copy link
Contributor

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

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 in Threshold-ts lib

Vending Machine

An interface of the wrapper for fetching on-chain data from the VendingMachine contract- the interface of update protocol to enable KEEP/NU token holders to wrap their tokens and obtain T tokens according to a fixed ratio. The Threshold lib creates a separate instance of the vending machine for KEEP holders and a separate instance of the vending machine for NU holders. Service covered with unit tests.

Staking

Adds function getOwnerStakes that fetches all stakes for a given owner address. Here we add legacy Keep and Nu staking contracts as private fields to the Staking service to calculate possible KEEP/NU top-up in T. Also pass Keep and Nu vending machines to convert KEEP/NU amount to T.

Utils functions

Move some contract-related utils functions from dashboard to the Threshold-ts lib.

This service is a wrappe for the VendingMachine contract in the
Threshold network. It implements an interface of update protocol to
enable KEEP/NU token holders to wrap their tokens and obtain T tokens
according to a fixed ratio.
Add a function that fetches the all stakes for a given owner address.
@github-actions
Copy link

github-actions bot commented Nov 9, 2022

Copy link
Contributor

@michalsmiarowski michalsmiarowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Left some small comments

@r-czajkowski r-czajkowski marked this pull request as ready for review November 18, 2022 08:39
@github-actions
Copy link

Copy link
Contributor

@michalsmiarowski michalsmiarowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@michalsmiarowski michalsmiarowski merged commit 472191b into main Nov 18, 2022
@michalsmiarowski michalsmiarowski deleted the threshold-lib-updates branch November 18, 2022 12:46
@michalsmiarowski michalsmiarowski added this to the v1.4.0 milestone Jan 31, 2023
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.

None yet

2 participants