diff --git a/abi/hardhat-diamond-abi/HardhatDiamondABI.sol/BestOfDiamond.json b/abi/hardhat-diamond-abi/HardhatDiamondABI.sol/BestOfDiamond.json index c4e4921..0ea39d9 100644 --- a/abi/hardhat-diamond-abi/HardhatDiamondABI.sol/BestOfDiamond.json +++ b/abi/hardhat-diamond-abi/HardhatDiamondABI.sol/BestOfDiamond.json @@ -1421,9 +1421,9 @@ }, { "indexed": false, - "internalType": "bytes32[]", + "internalType": "bytes32", "name": "votesHidden", - "type": "bytes32[]" + "type": "bytes32" }, { "indexed": false, @@ -1559,9 +1559,9 @@ "type": "uint256" }, { - "internalType": "bytes32[]", + "internalType": "bytes32", "name": "votesHash", - "type": "bytes32[]" + "type": "bytes32" }, { "internalType": "bytes", diff --git a/abi/src/facets/gameMastersFacet.sol/GameMastersFacet.json b/abi/src/facets/gameMastersFacet.sol/GameMastersFacet.json index e45511e..6e0b6bf 100644 --- a/abi/src/facets/gameMastersFacet.sol/GameMastersFacet.json +++ b/abi/src/facets/gameMastersFacet.sol/GameMastersFacet.json @@ -147,9 +147,9 @@ }, { "indexed": false, - "internalType": "bytes32[]", + "internalType": "bytes32", "name": "votesHidden", - "type": "bytes32[]" + "type": "bytes32" }, { "indexed": false, @@ -285,9 +285,9 @@ "type": "uint256" }, { - "internalType": "bytes32[]", + "internalType": "bytes32", "name": "votesHash", - "type": "bytes32[]" + "type": "bytes32" }, { "internalType": "bytes", diff --git a/deploy/01_deployRankToken.ts b/deploy/01_deployRankToken.ts index f43e788..19f188d 100644 --- a/deploy/01_deployRankToken.ts +++ b/deploy/01_deployRankToken.ts @@ -23,11 +23,12 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { } const owner = process.env.DAO_CONTRACT_ADDRESS || deployer; - await deploy('RankToken', { + const result = await deploy('RankToken', { from: deployer, args: [URI, owner, ContractURI, ethers.BigNumber.from(4)], skipIfAlreadyDeployed: true, }); + console.log('deployed rank token at', result.address); }; export default func; diff --git a/hardhat.config.ts b/hardhat.config.ts index e1e2b66..ebccdbe 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -82,9 +82,10 @@ export default { }, namedAccounts: { deployer: { - default: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', + default: '0x7231161f85637Dea4DCa51e30ff443eD508c3313', }, gameOwner: { + hardhat: '0xBfdF0Ee33BF4a2640D67f720Ae6594E81f8114d4', default: '0xE48BC6673B4EEBec6A230f9112Cb2c1ac17bc273', }, }, diff --git a/test/BestOfGame.ts b/test/BestOfGame.ts index 95ef3f6..e4048f9 100644 --- a/test/BestOfGame.ts +++ b/test/BestOfGame.ts @@ -210,9 +210,7 @@ const mockValidVotes = async ( if (submitNow) { votersAddresses = players.map(player => player.wallet.address); for (let i = 0; i < players.length; i++) { - await env.bestOfGame - .connect(players[i].wallet) - .submitVote(gameId, votes[i].voteHidden, votes[i].proof, votes[i].publicSignature); + await env.bestOfGame.connect(players[i].wallet).submitVote(gameId, votes[i].voteHidden, votes[i].proof); } } return votes; @@ -357,9 +355,11 @@ describe(scriptName, () => { ).to.revertedWith('LibDiamond: Must be contract owner'); }); it('has rank token assigned', async () => { + console.log(env.rankToken.address); const state = await env.bestOfGame.getContractState(); - await expect(state.BestOfState.rankTokenAddress).to.be.equal(env.rankToken.address); - expect(await env.rankToken.owner()).to.be.equal(env.bestOfGame.address); + expect(state.BestOfState.rankTokenAddress).to.be.equal(env.rankToken.address); + expect(await env.rankToken.getRankingInstance()).to.be.equal(env.bestOfGame.address); + expect(await env.rankToken.owner()).to.be.equal(adr.contractDeployer.wallet.address); }); it('Can create game only with valid payments', async () => { await expect( @@ -400,9 +400,7 @@ describe(scriptName, () => { distribution: 'semiUniform', }); await expect( - env.bestOfGame - .connect(adr.gameMaster1.wallet) - .submitVote(1, votes[0].voteHidden, votes[0].proof, votes[0].publicSignature), + env.bestOfGame.connect(adr.gameMaster1.wallet).submitVote(1, votes[0].voteHidden, votes[0].proof), ).to.be.revertedWith('no game found'); await expect(env.bestOfGame.connect(adr.gameMaster1.wallet).openRegistration(1)).to.be.revertedWith( 'no game found', @@ -559,9 +557,7 @@ describe(scriptName, () => { ), ).to.be.revertedWith('Game has not yet started'); await expect( - env.bestOfGame - .connect(adr.gameMaster1.wallet) - .submitVote(1, votes[0].voteHidden, votes[0].proof, votes[0].publicSignature), + env.bestOfGame.connect(adr.gameMaster1.wallet).submitVote(1, votes[0].voteHidden, votes[0].proof), ).to.be.revertedWith('Game has not yet started'); await expect(env.bestOfGame.connect(adr.gameCreator1.wallet).openRegistration(1)).to.be.revertedWith( 'Cannot do when registration is open', @@ -630,9 +626,7 @@ describe(scriptName, () => { ), ).to.be.revertedWith('Game has not yet started'); await expect( - env.bestOfGame - .connect(adr.gameMaster1.wallet) - .submitVote(1, votes[0].voteHidden, votes[0].proof, votes[0].publicSignature), + env.bestOfGame.connect(adr.gameMaster1.wallet).submitVote(1, votes[0].voteHidden, votes[0].proof), ).to.be.revertedWith('Game has not yet started'); }); describe('When game has started', () => { @@ -665,9 +659,7 @@ describe(scriptName, () => { votersAddresses = getPlayers(adr, BOGSettings.BOG_MAX_PLAYERS).map(player => player.wallet.address); await expect( - env.bestOfGame - .connect(adr.player1.wallet) - .submitVote(1, votes[0].voteHidden, votes[0].proof, votes[0].publicSignature), + env.bestOfGame.connect(adr.player1.wallet).submitVote(1, votes[0].voteHidden, votes[0].proof), ).to.be.revertedWith('No proposals exist at turn 1: cannot vote'); }); it('Processes only proposals only from game master', async () => { @@ -1043,9 +1035,7 @@ describe(scriptName, () => { let name = `player${i + 1}` as any as keyof AdrSetupResult; await expect( - env.bestOfGame - .connect(adr[`${name}`].wallet) - .submitVote(1, votes[i].voteHidden, votes[i].proof, votes[i].publicSignature), + env.bestOfGame.connect(adr[`${name}`].wallet).submitVote(1, votes[i].voteHidden, votes[i].proof), ).to.be.revertedWith('Game over'); } await expect( diff --git a/test/RankToken.ts b/test/RankToken.ts index 0730fd0..bc089ac 100644 --- a/test/RankToken.ts +++ b/test/RankToken.ts @@ -107,7 +107,7 @@ describe('Rank Token Test', async function () { it('reports correct balance of unlocked', async () => { expect( (await env.connect(adr.maliciousActor1.wallet).balanceOfUnlocked(adr.player1.wallet.address, 1)).toNumber(), - ).to.be.equal(2); + ).to.be.equal(2); }); it('Can be unlocked only by a rankingInstance', async () => { await expect(env.connect(rankingInstance).unlockFromInstance(adr.player1.wallet.address, 1, 1)) diff --git a/test/utils.ts b/test/utils.ts index 7356589..8f786c1 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -12,11 +12,12 @@ import { ProposalTypes } from '../types'; const { ZERO_ADDRESS, ZERO_BYTES32 } = require('@openzeppelin/test-helpers/src/constants'); import { BigNumber, BigNumberish, Bytes, BytesLike, Wallet } from 'ethers'; // @ts-ignore -import { RankToken } from '../types/typechain/contracts/tokens/RankToken'; -// import { BestOfInit } from "../types/typechain/contracts/initializers/BestOfInit"; +import { RankToken } from '../types/typechain/src/tokens/RankToken'; +// import { BestOfInit } from "../types/typechain/src/initializers/BestOfInit"; import { assert } from 'console'; import { Deployment } from 'hardhat-deploy/types'; import { HardhatEthersHelpers } from '@nomiclabs/hardhat-ethers/types'; +import { keccak256 } from 'ethers/lib/utils'; export interface SignerIdentity { name: string; @@ -611,7 +612,7 @@ export const getPlayers = ( export type MockVotes = Array<{ proof: string; vote: [BigNumberish, BigNumberish, BigNumberish]; - voteHidden: [BytesLike, BytesLike, BytesLike]; + voteHidden: string; publicSignature: string; }>; @@ -633,7 +634,7 @@ export const mockVotes = async ({ const votes: Array<{ proof: string; vote: [BigNumberish, BigNumberish, BigNumberish]; - voteHidden: [BytesLike, BytesLike, BytesLike]; + voteHidden: string; publicSignature: string; }> = []; for (let k = 0; k < players.length; k++) { @@ -688,7 +689,7 @@ export const mockVotes = async ({ verifierAddress, vote: [firstSelected, secondSelected, thirdSelected], }); - votes[k] = { vote, voteHidden, proof, publicSignature }; + votes[k] = { vote, voteHidden: keccak256(JSON.stringify(voteHidden)), proof, publicSignature }; } return votes; };