-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add validatorset methods to multisig * feat: delete redundant methods * feat: delete redundant comments * fix: implementation due to comments * feat: add admin methods to multisig * feat: delete redundant import * feat: add getBlockListener method * feat: add exports to consensus multisig methods * feat: add validatorSetGetStakesBalancesByManager method * fix: validatorSetGetStakesBalancesByManager method
- Loading branch information
1 parent
444a471
commit f034cb6
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Contracts } from "../../contracts/contracts"; | ||
import { ValidatorSet } from "../../../typechain-types"; | ||
import { ContractNames } from "../../contracts/names"; | ||
import { submitTransaction2 } from "./internal"; | ||
|
||
// view methods | ||
export async function validatorSetGetNodeStake(contracts: Contracts, nodeAddress: string) { | ||
const validatorSet = contracts.getContractByName(ContractNames.ValidatorSet) as ValidatorSet; | ||
return validatorSet.getNodeStake(nodeAddress); | ||
} | ||
|
||
export async function validatorSetGetValidators(contracts: Contracts) { | ||
const validatorSet = contracts.getContractByName(ContractNames.ValidatorSet) as ValidatorSet; | ||
return validatorSet.getValidators(); | ||
} | ||
|
||
export async function validatorSetGetTopStakes(contracts: Contracts) { | ||
const validatorSet = contracts.getContractByName(ContractNames.ValidatorSet) as ValidatorSet; | ||
return validatorSet.getTopStakes(); | ||
} | ||
|
||
export async function validatorSetGetQueuedStakes(contracts: Contracts) { | ||
const validatorSet = contracts.getContractByName(ContractNames.ValidatorSet) as ValidatorSet; | ||
return validatorSet.getQueuedStakes(); | ||
} | ||
|
||
export async function validatorSetGetStakesByManager(contracts: Contracts, managerAddress: string) { | ||
const validatorSet = contracts.getContractByName(ContractNames.ValidatorSet) as ValidatorSet; | ||
return validatorSet.getStakesByManager(managerAddress); | ||
} | ||
|
||
export async function validatorSetGetBlockListeners(contracts: Contracts) { | ||
const validatorSet = contracts.getContractByName(ContractNames.ValidatorSet) as ValidatorSet; | ||
return validatorSet.listeners(); | ||
} | ||
|
||
export async function validatorSetGetStakesBalancesByManager(contracts: Contracts, contractName: ContractNames) { | ||
const validatorSet = contracts.getContractByName(ContractNames.ValidatorSet) as ValidatorSet; | ||
const manager = contracts.getContractByName(contractName); | ||
const stakes = await validatorSetGetStakesByManager(contracts, manager.address); | ||
return await Promise.all( | ||
stakes.map((stakeAddress) => ({ address: stakeAddress, stake: validatorSet.getNodeStake(stakeAddress) })) | ||
); | ||
} | ||
|
||
// admin methods | ||
|
||
export async function validatorSetAddBlockListener(contracts: Contracts, listener: string) { | ||
return await submitTransaction2<ValidatorSet>(contracts, ContractNames.ValidatorSet, 0, (validatorSet) => | ||
validatorSet.addBlockListener(listener) | ||
); | ||
} | ||
|
||
export async function validatorSetRemoveBlockListener(contracts: Contracts, listener: string) { | ||
return await submitTransaction2<ValidatorSet>(contracts, ContractNames.ValidatorSet, 0, (validatorSet) => | ||
validatorSet.removeBlockListener(listener) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import * as finance from "./finance"; | ||
import * as staking from "./staking"; | ||
import * as multisigs from "./multisigs"; | ||
import * as consensus from "./consensus"; | ||
|
||
const Methods = { | ||
...multisigs, | ||
...finance, | ||
...staking, | ||
...consensus, | ||
}; | ||
|
||
export default Methods; |