refactor(VotingContract): rename public APIs
This commit is contained in:
parent
f090cce552
commit
03cd1915c8
|
@ -17,7 +17,7 @@ export function useCommunities(publicKeys: string[]) {
|
|||
return {
|
||||
abi: votingContract.interface,
|
||||
address: votingContract.address,
|
||||
method: 'getCommunityHistory',
|
||||
method: 'getVotingHistory',
|
||||
args: [publicKey],
|
||||
}
|
||||
})
|
||||
|
|
|
@ -12,7 +12,7 @@ export function useGetCurrentVoting(publicKey: string | undefined) {
|
|||
const votingRoom = useContractCall({
|
||||
abi: votingContract.interface,
|
||||
address: votingContract.address,
|
||||
method: 'getCommunityVoting',
|
||||
method: 'getActiveVotingRoom',
|
||||
args: [publicKey],
|
||||
}) as any
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ contract VotingContract {
|
|||
return votingRooms[roomID - 1];
|
||||
}
|
||||
|
||||
function getCommunityVoting(bytes calldata publicKey) public view returns (VotingRoom memory) {
|
||||
function getActiveVotingRoom(bytes calldata publicKey) public view returns (VotingRoom memory) {
|
||||
return _getVotingRoom(activeRoomIDByCommunityID[publicKey]);
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ contract VotingContract {
|
|||
return _getVotingRoom(roomId).voters;
|
||||
}
|
||||
|
||||
function getCommunityHistory(bytes calldata publicKey) public view returns (VotingRoom[] memory returnVotingRooms) {
|
||||
function getVotingHistory(bytes calldata publicKey) public view returns (VotingRoom[] memory returnVotingRooms) {
|
||||
returnVotingRooms = new VotingRoom[](roomIDsByCommunityID[publicKey].length);
|
||||
for (uint256 i = 0; i < roomIDsByCommunityID[publicKey].length; i++) {
|
||||
returnVotingRooms[i] = _getVotingRoom(roomIDsByCommunityID[publicKey][i]);
|
||||
|
|
|
@ -196,7 +196,7 @@ describe('VotingContract', () => {
|
|||
BigNumber.from(0),
|
||||
BigNumber.from(1),
|
||||
])
|
||||
const history = await votingContract.getCommunityHistory(publicKeys[0])
|
||||
const history = await votingContract.getVotingHistory(publicKeys[0])
|
||||
expect(history.length).to.eq(1)
|
||||
expect(history[0][2]).to.eq(1)
|
||||
expect(history[0][4]).to.eq(publicKeys[0])
|
||||
|
@ -225,11 +225,11 @@ describe('VotingContract', () => {
|
|||
const { votingContract, firstSigner } = await loadFixture(fixture)
|
||||
await votingContract.initializeVotingRoom(1, publicKeys[0], BigNumber.from(100))
|
||||
await voteAndFinalize(1, 1, firstSigner, votingContract)
|
||||
expect((await votingContract.getCommunityHistory(publicKeys[0])).length).to.eq(1)
|
||||
expect((await votingContract.getVotingHistory(publicKeys[0])).length).to.eq(1)
|
||||
await time.increase(10000)
|
||||
await votingContract.initializeVotingRoom(0, publicKeys[0], BigNumber.from(100))
|
||||
await voteAndFinalize(2, 0, firstSigner, votingContract)
|
||||
const history = await votingContract.getCommunityHistory(publicKeys[0])
|
||||
const history = await votingContract.getVotingHistory(publicKeys[0])
|
||||
expect(history.length).to.eq(2)
|
||||
expect(history[0][2]).to.eq(1)
|
||||
expect(history[0][3]).to.eq(true)
|
||||
|
@ -334,10 +334,10 @@ describe('VotingContract', () => {
|
|||
})
|
||||
|
||||
describe('helpers', () => {
|
||||
it('getCommunityVoting', async () => {
|
||||
it('getActiveVotingRoom', async () => {
|
||||
const { votingContract, firstSigner } = await loadFixture(fixture)
|
||||
await votingContract.initializeVotingRoom(1, publicKeys[0], BigNumber.from(100))
|
||||
expect((await votingContract.getCommunityVoting(publicKeys[0])).slice(2)).to.deep.eq([
|
||||
expect((await votingContract.getActiveVotingRoom(publicKeys[0])).slice(2)).to.deep.eq([
|
||||
1,
|
||||
false,
|
||||
publicKeys[0],
|
||||
|
@ -349,7 +349,7 @@ describe('VotingContract', () => {
|
|||
|
||||
await time.increase(10000)
|
||||
await votingContract.initializeVotingRoom(1, publicKeys[1], BigNumber.from(100))
|
||||
expect((await votingContract.getCommunityVoting(publicKeys[1])).slice(2)).to.deep.eq([
|
||||
expect((await votingContract.getActiveVotingRoom(publicKeys[1])).slice(2)).to.deep.eq([
|
||||
1,
|
||||
false,
|
||||
publicKeys[1],
|
||||
|
|
Loading…
Reference in New Issue