@celo/contractkit › "wrappers/Election" › ElectionWrapper
Class: ElectionWrapper
Contract for voting for validators and managing validator groups.
Hierarchy
- BaseWrapper‹Election›
↳ ElectionWrapper
Index
Constructors
Properties
- electabilityThreshold
- eventTypes
- events
- getCurrentValidatorSigners
- getGroupsVotedForByAccount
- getTotalVotes
- getTotalVotesByAccount
- getTotalVotesForGroupByAccount
- methodIds
- numberValidatorsInCurrentSet
- numberValidatorsInSet
- validatorSignerAddressFromCurrentSet
- validatorSignerAddressFromSet
Accessors
Methods
- activate
- electValidatorSigners
- electableValidators
- findLesserAndGreaterAfterVote
- getActiveVotesForGroup
- getConfig
- getElectedValidators
- getEligibleValidatorGroupsVotes
- getGroupVoterRewards
- getPastEvents
- getTotalVotesForGroup
- getValidatorGroupVotes
- getValidatorGroupsVotes
- getValidatorSigners
- getVoter
- getVoterRewards
- getVoterShare
- getVotesForGroupByAccount
- hasActivatablePendingVotes
- hasPendingVotes
- revoke
- revokeActive
- revokePending
- version
- vote
Constructors
constructor
+ new ElectionWrapper(kit
: ContractKit, contract
: Election): ElectionWrapper
Inherited from BaseWrapper.constructor
Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:30
Parameters:
Name | Type |
---|---|
kit |
ContractKit |
contract |
Election |
Returns: ElectionWrapper
Properties
electabilityThreshold
• electabilityThreshold: function = proxyCall( this.contract.methods.getElectabilityThreshold, undefined, fixidityValueToBigNumber )
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:86
Returns the current election threshold.
returns
Election threshold.
Type declaration:
▸ (...args
: InputArgs): Promise‹Output›
Parameters:
Name | Type |
---|---|
...args |
InputArgs |
eventTypes
• eventTypes: EventsEnum‹T› = Object.keys(this.events).reduce
Inherited from BaseWrapper.eventTypes
Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:61
events
• events: Election["events"] = this.contract.events
Inherited from BaseWrapper.events
Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:59
getCurrentValidatorSigners
• getCurrentValidatorSigners: function = proxyCall( this.contract.methods.getCurrentValidatorSigners )
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:144
Returns the current validator signers using the precompiles.
returns
List of current validator signers.
Type declaration:
▸ (): Promise‹Address[]›
getGroupsVotedForByAccount
• getGroupsVotedForByAccount: function = proxyCall( this.contract.methods.getGroupsVotedForByAccount )
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:217
Returns the groups that account
has voted for.
param
The address of the account casting votes.
returns
The groups that account
has voted for.
Type declaration:
▸ (account
: Address): Promise‹Address[]›
Parameters:
Name | Type |
---|---|
account |
Address |
getTotalVotes
• getTotalVotes: function = proxyCall(this.contract.methods.getTotalVotes, undefined, valueToBigNumber)
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:138
Returns the total votes received across all groups.
returns
The total votes received across all groups.
Type declaration:
▸ (...args
: InputArgs): Promise‹Output›
Parameters:
Name | Type |
---|---|
...args |
InputArgs |
getTotalVotesByAccount
• getTotalVotesByAccount: function = proxyCall( this.contract.methods.getTotalVotesByAccount, undefined, valueToBigNumber )
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:255
Type declaration:
▸ (...args
: InputArgs): Promise‹Output›
Parameters:
Name | Type |
---|---|
...args |
InputArgs |
getTotalVotesForGroupByAccount
• getTotalVotesForGroupByAccount: function = proxyCall( this.contract.methods.getTotalVotesForGroupByAccount, undefined, valueToBigNumber )
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:195
Returns the total votes for group
made by account
.
param
The address of the validator group.
param
The address of the voting account.
returns
The total votes for group
made by account
.
Type declaration:
▸ (...args
: InputArgs): Promise‹Output›
Parameters:
Name | Type |
---|---|
...args |
InputArgs |
methodIds
• methodIds: Record‹keyof T["methods"], string› = Object.keys(this.contract.methods).reduce
acc[method] =
methodABI === undefined
? '0x'
: this.kit.connection.getAbiCoder().encodeFunctionSignature(methodABI)
return acc
},
{} as any
)
Inherited from BaseWrapper.methodIds
Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:66
numberValidatorsInCurrentSet
• numberValidatorsInCurrentSet: function = proxyCall( this.contract.methods.numberValidatorsInCurrentSet, undefined, valueToInt )
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:128
Gets the size of the current elected validator set.
returns
Size of the current elected validator set.
Type declaration:
▸ (...args
: InputArgs): Promise‹Output›
Parameters:
Name | Type |
---|---|
...args |
InputArgs |
numberValidatorsInSet
• numberValidatorsInSet: function = proxyCall( this.contract.methods.numberValidatorsInSet, undefined, valueToInt )
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:118
Gets the size of the validator set that must sign the given block number.
param
Block number to retrieve the validator set from.
returns
Size of the validator set.
Type declaration:
▸ (blockNumber
: number): Promise‹number›
Parameters:
Name | Type |
---|---|
blockNumber |
number |
validatorSignerAddressFromCurrentSet
• validatorSignerAddressFromCurrentSet: function = proxyCall(
this.contract.methods.validatorSignerAddressFromCurrentSet,
tupleParser
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:108
Gets a validator address from the current validator set.
param
Index of requested validator in the validator set.
returns
Address of validator at the requested index.
Type declaration:
▸ (index
: number): Promise‹Address›
Parameters:
Name | Type |
---|---|
index |
number |
validatorSignerAddressFromSet
• validatorSignerAddressFromSet: function = proxyCall(this.contract.methods.validatorSignerAddressFromSet)
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:98
Gets a validator address from the validator set at the given block number.
param
Index of requested validator in the validator set.
param
Block number to retrieve the validator set from.
returns
Address of validator at the requested index.
Type declaration:
▸ (signerIndex
: number, blockNumber
: number): Promise‹Address›
Parameters:
Name | Type |
---|---|
signerIndex |
number |
blockNumber |
number |
Accessors
address
• get address(): string
Inherited from BaseWrapper.address
Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:35
Contract address
Returns: string
Methods
activate
▸ activate(account
: Address): Promise‹Array‹CeloTransactionObject‹boolean›››
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:334
Activates any activatable pending votes.
Parameters:
Name | Type | Description |
---|---|---|
account |
Address | The account with pending votes to activate. |
Returns: Promise‹Array‹CeloTransactionObject‹boolean›››
electValidatorSigners
▸ electValidatorSigners(min?
: undefined | number, max?
: undefined | number): Promise‹Address[]›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:165
Returns a list of elected validators with seats allocated to groups via the D'Hondt method.
dev
See https://en.wikipedia.org/wiki/D%27Hondt_method#Allocation for more information.
Parameters:
Name | Type |
---|---|
min? |
undefined | number |
max? |
undefined | number |
Returns: Promise‹Address[]›
The list of elected validators.
electableValidators
▸ electableValidators(): Promise‹ElectableValidators›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:77
Returns the minimum and maximum number of validators that can be elected.
Returns: Promise‹ElectableValidators›
The minimum and maximum number of validators that can be elected.
findLesserAndGreaterAfterVote
▸ findLesserAndGreaterAfterVote(votedGroup
: Address, voteWeight
: BigNumber): Promise‹object›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:426
Parameters:
Name | Type |
---|---|
votedGroup |
Address |
voteWeight |
BigNumber |
Returns: Promise‹object›
getActiveVotesForGroup
▸ getActiveVotesForGroup(group
: Address, blockNumber?
: undefined | number): Promise‹BigNumber›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:206
Returns the active votes for group
.
Parameters:
Name | Type | Description |
---|---|---|
group |
Address | The address of the validator group. |
blockNumber? |
undefined | number | - |
Returns: Promise‹BigNumber›
The active votes for group
.
getConfig
▸ getConfig(): Promise‹ElectionConfig›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:289
Returns current configuration parameters.
Returns: Promise‹ElectionConfig›
getElectedValidators
▸ getElectedValidators(epochNumber
: number): Promise‹Validator[]›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:455
Retrieves the set of validatorsparticipating in BFT at epochNumber.
Parameters:
Name | Type | Description |
---|---|---|
epochNumber |
number | The epoch to retrieve the elected validator set at. |
Returns: Promise‹Validator[]›
getEligibleValidatorGroupsVotes
▸ getEligibleValidatorGroupsVotes(): Promise‹ValidatorGroupVote[]›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:411
Returns the current eligible validator groups and their total votes.
Returns: Promise‹ValidatorGroupVote[]›
getGroupVoterRewards
▸ getGroupVoterRewards(epochNumber
: number): Promise‹GroupVoterReward[]›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:466
Retrieves GroupVoterRewards at epochNumber.
Parameters:
Name | Type | Description |
---|---|---|
epochNumber |
number | The epoch to retrieve GroupVoterRewards at. |
Returns: Promise‹GroupVoterReward[]›
getPastEvents
▸ getPastEvents(event
: Events‹Election›, options
: PastEventOptions): Promise‹EventLog[]›
Inherited from BaseWrapper.getPastEvents
Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:55
Contract getPastEvents
Parameters:
Name | Type |
---|---|
event |
Events‹Election› |
options |
PastEventOptions |
Returns: Promise‹EventLog[]›
getTotalVotesForGroup
▸ getTotalVotesForGroup(group
: Address, blockNumber?
: undefined | number): Promise‹BigNumber›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:183
Returns the total votes for group
.
Parameters:
Name | Type | Description |
---|---|---|
group |
Address | The address of the validator group. |
blockNumber? |
undefined | number | - |
Returns: Promise‹BigNumber›
The total votes for group
.
getValidatorGroupVotes
▸ getValidatorGroupVotes(address
: Address): Promise‹ValidatorGroupVote›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:305
Parameters:
Name | Type |
---|---|
address |
Address |
Returns: Promise‹ValidatorGroupVote›
getValidatorGroupsVotes
▸ getValidatorGroupsVotes(): Promise‹ValidatorGroupVote[]›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:322
Returns the current registered validator groups and their total votes and eligibility.
Returns: Promise‹ValidatorGroupVote[]›
getValidatorSigners
▸ getValidatorSigners(blockNumber
: number): Promise‹Address[]›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:153
Returns the validator signers for block blockNumber
.
Parameters:
Name | Type | Description |
---|---|---|
blockNumber |
number | Block number to retrieve signers for. |
Returns: Promise‹Address[]›
Address of each signer in the validator set.
getVoter
▸ getVoter(account
: Address, blockNumber?
: undefined | number): Promise‹Voter›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:243
Parameters:
Name | Type |
---|---|
account |
Address |
blockNumber? |
undefined | number |
Returns: Promise‹Voter›
getVoterRewards
▸ getVoterRewards(address
: Address, epochNumber
: number, voterShare?
: Record‹Address, BigNumber›): Promise‹VoterReward[]›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:491
Retrieves VoterRewards for address at epochNumber.
Parameters:
Name | Type | Description |
---|---|---|
address |
Address | The address to retrieve VoterRewards for. |
epochNumber |
number | The epoch to retrieve VoterRewards at. |
voterShare? |
Record‹Address, BigNumber› | Optionally address' share of group rewards. |
Returns: Promise‹VoterReward[]›
getVoterShare
▸ getVoterShare(address
: Address, blockNumber?
: undefined | number): Promise‹Record‹Address, BigNumber››
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:521
Retrieves a voter's share of active votes.
Parameters:
Name | Type | Description |
---|---|---|
address |
Address | The voter to retrieve share for. |
blockNumber? |
undefined | number | The block to retrieve the voter's share at. |
Returns: Promise‹Record‹Address, BigNumber››
getVotesForGroupByAccount
▸ getVotesForGroupByAccount(account
: Address, group
: Address, blockNumber?
: undefined | number): Promise‹GroupVote›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:221
Parameters:
Name | Type |
---|---|
account |
Address |
group |
Address |
blockNumber? |
undefined | number |
Returns: Promise‹GroupVote›
hasActivatablePendingVotes
▸ hasActivatablePendingVotes(account
: Address): Promise‹boolean›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:278
Parameters:
Name | Type |
---|---|
account |
Address |
Returns: Promise‹boolean›
hasPendingVotes
▸ hasPendingVotes(account
: Address): Promise‹boolean›
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:266
Returns whether or not the account has any pending votes.
Parameters:
Name | Type | Description |
---|---|---|
account |
Address | The address of the account casting votes. |
Returns: Promise‹boolean›
The groups that account
has voted for.
revoke
▸ revoke(account
: Address, group
: Address, value
: BigNumber): Promise‹Array‹CeloTransactionObject‹boolean›››
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:373
Parameters:
Name | Type |
---|---|
account |
Address |
group |
Address |
value |
BigNumber |
Returns: Promise‹Array‹CeloTransactionObject‹boolean›››
revokeActive
▸ revokeActive(account
: Address, group
: Address, value
: BigNumber): Promise‹CeloTransactionObject‹boolean››
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:358
Parameters:
Name | Type |
---|---|
account |
Address |
group |
Address |
value |
BigNumber |
Returns: Promise‹CeloTransactionObject‹boolean››
revokePending
▸ revokePending(account
: Address, group
: Address, value
: BigNumber): Promise‹CeloTransactionObject‹boolean››
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:343
Parameters:
Name | Type |
---|---|
account |
Address |
group |
Address |
value |
BigNumber |
Returns: Promise‹CeloTransactionObject‹boolean››
version
▸ version(): Promise‹NonNullable‹T["methods"] extends object ? ContractVersion<> : never››
Inherited from BaseWrapper.version
Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:39
Returns: Promise‹NonNullable‹T["methods"] extends object ? ContractVersion<> : never››
vote
▸ vote(validatorGroup
: Address, value
: BigNumber): Promise‹CeloTransactionObject‹boolean››
Defined in packages/sdk/contractkit/src/wrappers/Election.ts:399
Increments the number of total and pending votes for group
.
Parameters:
Name | Type | Description |
---|---|---|
validatorGroup |
Address | The validator group to vote for. |
value |
BigNumber | The amount of gold to use to vote. |
Returns: Promise‹CeloTransactionObject‹boolean››