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

Display current account locked gold requirement in lockedgold:show #1923

Merged
merged 5 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/commands/lockedgold/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Args } from '../../utils/command'

export default class Show extends BaseCommand {
static description =
'Show Locked Gold information for a given account. This includes the total amount of locked gold, the amount being used for voting in Validator Elections, and any pending withdrawals that have been initiated via "lockedgold:unlock".'
'Show Locked Gold information for a given account. This includes the total amount of locked gold, the amount being used for voting in Validator Elections, the Locked Gold balance this account is required to maintain due to a registered Validator or Validator Group, and any pending withdrawals that have been initiated via "lockedgold:unlock".'

static flags = {
...BaseCommand.flags,
Expand Down
4 changes: 4 additions & 0 deletions packages/contractkit/src/wrappers/LockedGold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface AccountSummary {
lockedGold: {
total: BigNumber
nonvoting: BigNumber
requirement: BigNumber
}
pendingWithdrawals: PendingWithdrawal[]
}
Expand Down Expand Up @@ -155,11 +156,14 @@ export class LockedGoldWrapper extends BaseWrapper<LockedGold> {
async getAccountSummary(account: string): Promise<AccountSummary> {
const nonvoting = await this.getAccountNonvotingLockedGold(account)
const total = await this.getAccountTotalLockedGold(account)
const validators = await this.kit.contracts.getValidators()
const requirement = await validators.getAccountLockedGoldRequirement(account)
const pendingWithdrawals = await this.getPendingWithdrawals(account)
return {
lockedGold: {
total,
nonvoting,
requirement,
},
pendingWithdrawals,
}
Expand Down
10 changes: 10 additions & 0 deletions packages/contractkit/src/wrappers/Validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ export class ValidatorsWrapper extends BaseWrapper<Validators> {
}
}

/**
* Returns the Locked Gold requirements for specific account.
* @returns The Locked Gold requirements for a specific account.
*/
getAccountLockedGoldRequirement = proxyCall(
this.contract.methods.getAccountLockedGoldRequirement,
undefined,
toBigNumber
)

/**
* Returns current configuration parameters.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/command-line-interface/lockedgold.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ _See code: [packages/cli/src/commands/lockedgold/lock.ts](https://github.com/cel

### Show

Show Locked Gold information for a given account. This includes the total amount of locked gold, the amount being used for voting in Validator Elections, and any pending withdrawals that have been initiated via "lockedgold:unlock".
Show Locked Gold information for a given account. This includes the total amount of locked gold, the amount being used for voting in Validator Elections, the Locked Gold balance this account is required to maintain due to a registered Validator or Validator Group, and any pending withdrawals that have been initiated via "lockedgold:unlock".

```
USAGE
Expand Down
6 changes: 4 additions & 2 deletions packages/protocol/contracts/governance/Validators.sol
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ contract Validators is
* @param index The index of this validator in the list of all registered validators.
* @return True upon success.
* @dev Fails if the account is not a validator.
* @dev Fails if the validator has been a member of a group too recently.
*/
function deregisterValidator(uint256 index) external nonReentrant returns (bool) {
address account = getAccounts().signerToAccount(msg.sender);
Expand Down Expand Up @@ -587,6 +588,7 @@ contract Validators is
* @param index The index of this validator group in the list of all validator groups.
* @return True upon success.
* @dev Fails if the account is not a validator group with no members.
* @dev Fails if the group has had members too recently.
*/
function deregisterValidatorGroup(uint256 index) external nonReentrant returns (bool) {
address account = getAccounts().signerToAccount(msg.sender);
Expand Down Expand Up @@ -720,9 +722,9 @@ contract Validators is
}

/**
* @notice Returns the locked gold balance requirement for the supplied account.
* @notice Returns the current locked gold balance requirement for the supplied account.
* @param account The account that may have to meet locked gold balance requirements.
* @return The locked gold balance requirement for the supplied account.
* @return The current locked gold balance requirement for the supplied account.
*/
function getAccountLockedGoldRequirement(address account) public view returns (uint256) {
if (isValidator(account)) {
Expand Down