Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

feat(storage): staking support #286

Merged
merged 29 commits into from
Sep 25, 2020
Merged

feat(storage): staking support #286

merged 29 commits into from
Sep 25, 2020

Conversation

nduchak
Copy link
Contributor

@nduchak nduchak commented Sep 2, 2020

This PR introduces listening and handling of Staking Contract Events

@nduchak nduchak self-assigned this Sep 2, 2020
@nduchak nduchak marked this pull request as ready for review September 8, 2020 10:26
@nduchak nduchak requested review from julianmrodri and AuHau and removed request for julianmrodri September 8, 2020 10:26
AuHau
AuHau previously approved these changes Sep 9, 2020
@AuHau AuHau dismissed their stale review September 9, 2020 07:02

accidental review

Copy link
Contributor

@AuHau AuHau left a comment

Choose a reason for hiding this comment

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

LGTM, except on the handler structure, that I don't like.

src/services/storage/handlers/stake.ts Outdated Show resolved Hide resolved
src/services/storage/handlers/stake.ts Outdated Show resolved Hide resolved
src/services/storage/index.ts Outdated Show resolved Hide resolved
src/cli/start.ts Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Sep 9, 2020

This pull request introduces 1 alert when merging 5c6a63f into 4d48f80 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Sep 9, 2020

This pull request introduces 1 alert when merging 19d119f into 4d48f80 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

Copy link
Contributor

@AuHau AuHau left a comment

Choose a reason for hiding this comment

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

Few suggestions

src/services/storage/handlers/stake.ts Outdated Show resolved Hide resolved
src/services/storage/handlers/stake.ts Show resolved Hide resolved
src/services/storage/index.ts Outdated Show resolved Hide resolved
src/services/storage/index.ts Outdated Show resolved Hide resolved
src/services/storage/index.ts Outdated Show resolved Hide resolved
src/services/storage/index.ts Outdated Show resolved Hide resolved
src/services/storage/index.ts Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Sep 9, 2020

This pull request introduces 1 alert when merging 7ed468b into 4d48f80 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Sep 9, 2020

This pull request introduces 1 alert when merging 3658eb9 into 4d48f80 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@AuHau AuHau added the blocked Blocked by another issue label Sep 9, 2020
@AuHau
Copy link
Contributor

AuHau commented Sep 9, 2020

Btw. this PR is blocked until the Staking PR is merged and released :-)
That is the reason why CircleCI is not passing as using Git URL as package's dependency won't work here, as we don't keep the builded contracts in the repo.

Copy link
Contributor

@AuHau AuHau left a comment

Choose a reason for hiding this comment

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

LGTM, now we only have to release the Staking part of the SC.

@nduchak
Copy link
Contributor Author

nduchak commented Sep 9, 2020

Blocked by: rsksmart/rif-marketplace-storage#112

@nduchak
Copy link
Contributor Author

nduchak commented Sep 9, 2020

Closes #284

@nduchak nduchak requested a review from AuHau September 15, 2020 15:05
Copy link
Contributor

@AuHau AuHau left a comment

Choose a reason for hiding this comment

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

I don't really agree with the approach for fetching the token's symbol. I would just use config and have configured tokens and their addresses. Simplicity FTW here...

src/services/storage/handlers/stake.ts Outdated Show resolved Hide resolved
src/services/storage/handlers/stake.ts Outdated Show resolved Hide resolved
}

const contract = new eth.Contract(tokenAbi, token)
return contract.methods.symbol().call({ from: eth.accounts.create() })
Copy link
Contributor

Choose a reason for hiding this comment

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

Ufff, so you are calling the ERC20 contract here to resolve for given token address its symbol here? I am not sure this is a good approach. How fast is this call? Also, how do you make sure that this is actually value defined in SupportedTokens?

I would say first of all we want have defined list of tokens that we support (most probably already mentioned config should be good place to have it there) and since we gonna do that we can add their address as well? We already do this for every other interaction with blockchain, so I would say it is standard and it will saves us lot of this work, that I am not sure if actually bring many benefits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... The call is fast enough (it's static call), but I agree that tokens in the config would be better

test/services/storage/models.spec.ts Outdated Show resolved Hide resolved
src/services/storage/models/stake.model.ts Outdated Show resolved Hide resolved
src/services/storage/models/offer.model.ts Show resolved Hide resolved
test/utils.ts Show resolved Hide resolved
Copy link
Contributor

@AuHau AuHau left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for implementing the suggestions!

prepare staking contract event handling
use literals in offer scope where statement(allow to cast string to number on db layer)
fix stakes events handlers
add stake service to channel
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 4 Code Smells

No Coverage information No Coverage information
8.4% 8.4% Duplication

@AuHau AuHau removed the blocked Blocked by another issue label Sep 24, 2020
@AuHau AuHau changed the title feat: staking events feat(storage): staking support Sep 25, 2020
@AuHau AuHau merged commit 7be56f7 into master Sep 25, 2020
@AuHau AuHau deleted the feat/stacking branch September 25, 2020 07:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants