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
[IIP-13] contract staking struct definition (1/3 split by 3853) #3861
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3861 +/- ##
==========================================
- Coverage 75.38% 75.18% -0.20%
==========================================
Files 303 306 +3
Lines 25923 26166 +243
==========================================
+ Hits 19541 19672 +131
- Misses 5360 5476 +116
+ Partials 1022 1018 -4
... and 6 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
} | ||
|
||
// Serialize serializes the bucket type | ||
func (bt *BucketType) Serialize() []byte { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public funs are laid above private funcs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Index uint64 | ||
Candidate address.Address | ||
Owner address.Address | ||
StakedAmount *big.Int | ||
StakedDurationBlockNumber uint64 | ||
CreateBlockHeight uint64 | ||
StakeStartBlockHeight uint64 | ||
UnstakeStartBlockHeight uint64 | ||
AutoStake bool | ||
ContractAddress string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments
bi.Owner, err = address.FromString(p.Owner) | ||
if err != nil { | ||
return err | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delegate, err = address.FromString(p.Delegate)
if err != nil {
return err
}
owner, err := address.FromString(p.Owner)
if err != nil {
return err
}
bi.TypeIndex = p.TypeIndex
bi.CreatedAt = p.CreatedAt
bi.UnlockedAt = p.UnlockedAt
bi.UnstakedAt = p.UnstakedAt
bi.Delegate = delegate
bi.Owner = owner
return nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
func (bt *BucketType) loadProto(p *contractstakingpb.BucketType) error { | ||
var ok bool | ||
bt.Amount, ok = big.NewInt(0).SetString(p.Amount, 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
StakeStartBlockHeight uint64 | ||
UnstakeStartBlockHeight uint64 | ||
AutoStake bool | ||
ContractAddress string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is this necessary?
in other words, this is for the possibility that there's another LSD staking contract in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah
UnstakeStartBlockHeight uint64 | ||
AutoStake bool | ||
ContractAddress string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no Serialize
and Deserialize
code here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useless for Bucket
, which is only in memory
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Description
For #3853 is too large to review, it has been splited into three small pr. This is the first one.
Fixes #(issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: