diff --git a/.changeset/hungry-doors-beam.md b/.changeset/hungry-doors-beam.md new file mode 100644 index 00000000..7fea1445 --- /dev/null +++ b/.changeset/hungry-doors-beam.md @@ -0,0 +1,8 @@ +--- +'rankify-contracts': patch +--- + +# Documentation updated +- All source code signatures now are exported during release to docs/selectors.md +- fixed typos +- Removed obsolete documentation diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f457308e..185ada91 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ on: concurrency: ${{ github.workflow }}-${{ github.ref }} permissions: {} -env: +env: FORK_RPC_URL: ${{ secrets.FORK_RPC_URL }} jobs: release: @@ -28,6 +28,8 @@ jobs: run: pnpm install - name: generate docs run: pnpm hardhat docgen + - name: generate doc selectors + run: pnpm hardhat generate-selector-docs - name: Create Release Pull Request or Publish to npm uses: changesets/action@v1 with: diff --git a/.gitignore b/.gitignore index 81083520..41a1b9d8 100644 --- a/.gitignore +++ b/.gitignore @@ -276,4 +276,5 @@ bin/ /deployments/hardhat/ abi/ -docs/contracts/ \ No newline at end of file +docs/contracts/ +docs/selectors.md \ No newline at end of file diff --git a/docs/gm.mdx b/docs/gm.mdx deleted file mode 100644 index bd4133ff..00000000 --- a/docs/gm.mdx +++ /dev/null @@ -1,40 +0,0 @@ -# What is Game Master protocol? - -Implements an optimistic intermediatory signer for submitting temporary anonymous proposals on chain. - -## Definitions - -- `GM` - Gam master: an off-chain server or human who submits and signs transactions upon request -- `Proposer` - EOA that submits a proposal messages to -- `Proposal` - 32 bytes data -- `Turn` - Proposals batching in to a block (one proposal per sender) -- `GM Contract` - on chain protocol piece that is set to trust a particular GM - -## Workflow - -For each turn there can be set of Proposals as well as set of Votes except for first and last trun. Votes are submitted for a previous turn proposals. Hence on first turn only propisals can be sumitted and at last turn no proposals is accepted. - -**Proposing: ** - -0. For each turn alculates **salt** as hashed combination of own private key & nonce -1. protocol user, **proposer**: sends to GM a message (via private communication channel) containing data to post to chain and his signature that enables game master to do so. -2. GM Takes that message and calculates anonymous proposer identificator by hashing proposer address with turn **salt** -3. GM submits (using own gas) data on-chain together with anonymous proposer identificator in to contract that implements GM Contract - -**Voting** - -0. Voter sends his vote for some of proposals active in the turn to GM. GM returns back hash of the vote with the salt. -1. Voter then submits this hash to GM Contract. GM contract validates voter address as well as GM signature. -2. Upon turn end GM submits a transaction that contains not only revealed proposers, but also a revealed voters - -** Upon end of turn** - -GM submits another transaction to GM Contract. This tx contains revealed proposers addresses as well as **salt** used in that turn. GM Contract then runs signature verification logic and ensures that revealed proposers addresses indeed matches to anonymous indentificator and that the proofs were really generated by revealed proposers. - -## Payments - -In order for Game Master to sign or send transactions it has to be funded. It is still to be implemented but basically GM operator will be taking fee by supporting these operations - -## Privacy - -It is up for GM operator to guarantee user data privacy. It can be done trough service level agreements OR by building GM on a TEE based technologies such as iExec. diff --git a/docs/uml/EndTurnSequence.zenuml b/docs/uml/EndTurnSequence.zenuml deleted file mode 100644 index 5f6ec8fb..00000000 --- a/docs/uml/EndTurnSequence.zenuml +++ /dev/null @@ -1,51 +0,0 @@ -GameMaster.hostGame(gameId) { - //cron job - while(gameNotFinished) - { - gameState = GameContract.gameState(gameId) - - if(gameState.canEndTurn) - { - - encrVotes,encrProposals = EventLogs.getLogs(game,turn) - proposals, votes, vSigs = KeyStore.decrypt(encrVotes,encrProposals) - KeyStore.getTurnSalt(gameid,turn) - { - return tSalt = hash(PK,gameId,turn) - } - GameContract.endTurn(gameId,votes,newPropos,tSalt,vSigs) - { - newProposalsAreLegit = GameContract.validateNextProposals(gameId,newPropos,tSalt) - { - newProposalsChecksum = GameStorage.getFutureProposalsChecksum(gameId) - newProposalsAreLegit = _(hash(tSalt,newProposals) == proposalsChecksum) - - } - if(!newProposalsAreLegit) - { - return revert - } - - - proposals = GameStorage.getOldProposals(gameId) - while (votes) { - checksum = GameStorage.getVotingProof(player) - playerSalt = hash(playerId,turnSalt) - isPlayersVote = _(checksum == hash(vote,signature,playerSalt)) - if(!isLegitVote(vote,proposals) || !isValidSig(vote,voteSig,playerId)) - { - return revert - } - GameStorage.updateScores(gameId,vote) - } - - GameStorage.setNewProposals(newProposals) - return receipt - - - } - } - } - - return stopService -} \ No newline at end of file diff --git a/docs/uml/GMHandShake.zenuml b/docs/uml/GMHandShake.zenuml deleted file mode 100644 index 2509f10b..00000000 --- a/docs/uml/GMHandShake.zenuml +++ /dev/null @@ -1,26 +0,0 @@ -while(allParticipants) -{ParticipantA -> GameMaster.wantToJoin(EOA_adr,Signature) { - playerSecret = KeyStore.getPrivateKeyByIdx(int(EOA_adr)) - sharedEOA = fromPrivateKey(secretShare) - signature = KeyStore.sign(EOA_adr,sharedEOA) - return _(secretShare,gmSignature) - } -ParticipantA.importShare -{ - sharedEOA = fromPrivateKey(secretShare) - ParticipantA -> GameMaster.sign(ackMessage,secretShare) - if(signatureValid) - { - return gmSignature - } -} -ParticipantA.joinsGame() -{ - -sharedEOA = fromPrivateKey(secretShare) -ParticipantA -> GameContract.joinGame(EOA_adr,sharedEOA,gmSignature,ParticipantSignature){ - EventLogs.Joined(EOA_adr,gmSignature,sharedEOA) -} -} -} - diff --git a/docs/uml/GovernanceRoadmap.zenuml b/docs/uml/GovernanceRoadmap.zenuml deleted file mode 100644 index dae71799..00000000 --- a/docs/uml/GovernanceRoadmap.zenuml +++ /dev/null @@ -1,14 +0,0 @@ -@start EOA -MultiSig.Stage1 -{ -whileInTest = SoloSigner -whenINProd = addSignersAdHoc -DAO.Stage2 -{ - MintTokensToMultisig - whileInPrivate - DAO.stage3(ICO) - //Governance decisions - DAOv2.stage4() -} -} \ No newline at end of file diff --git a/docs/uml/OverviewSequence.zenuml b/docs/uml/OverviewSequence.zenuml deleted file mode 100644 index 0711fe98..00000000 --- a/docs/uml/OverviewSequence.zenuml +++ /dev/null @@ -1,28 +0,0 @@ -@start GameOwner -new RankToken(URI,Owner) -{ - return rankTokenReceipt -} - -new GameContract() -// Settings include RankTokenAddress, game prices, player numbers etc -GameContract.init(settings) -{ - return gameReceipt -} -RankToken.transferOwnership(gameReceipt.address) -new governanceToken(initialHolders,values) -{ - batchMint(initialHolders,values) - return governanceTokenReceipt -} - -new DAO(governanceTokenReceipt.address) -{ - return DAOreceipt -} - -GameContract.transferOwnership(DAOreceipt.address) -{ - return receipt -} \ No newline at end of file diff --git a/docs/uml/ProposingSequence.zenuml b/docs/uml/ProposingSequence.zenuml deleted file mode 100644 index d9506019..00000000 --- a/docs/uml/ProposingSequence.zenuml +++ /dev/null @@ -1,72 +0,0 @@ - -Player.proposes(proposal){ - GameMaster.getPlayersSalt(playerId,turn+1,gameId) - { - if(notAuthorized(playerId,EEAToken)) - { - return Error(403) - } - salt = KeyStore.getPlayerSalt(gameid,turn+1,playerId) - { - turnSalt = hash(PK,gameId,turn) - playerSalt = hash(turnSalt,playerId) - } - return playerSalt - } - commitement,hiddenPreimage = EventLogs.getLogs("CommitedProposing", playerId, turn-1) - preImage = decrypt(hiddenPreimage) - // players commitement for proposing this in given turn - propId = hash(playerSalt,proposal) - sig = Player.sign(propId) - proof = generateSnarkProof(hiddenPreimage) - gmSignature,hiddenProposal = GameMaster.apostile(propId,gameId,turn,sig,playerId) - // proposal identifier - proposalStruct = _(gameId,turn,sig,proposal,propId) - - proposalId = hash(preImage.nullifier) - GameContract.submitProposal(gmSignature,hiddenProposal,proposalId) - { - validSig = GameContract.validateSig(playerId,propId,sig) - proposed = GameStorage.proposalExists(gameId,turn,playerId) - if(!validProof || !validSig || proposed) - { - return revert - } - GameStorage.setProposals(playerId,propId) - if(GameStorage.voted(playerId) || turn ==1) - { - GameStorage.playerMove(gameId,player) - } - EventLogs.Proposed(gameId,turn,encProposal,playerId,sig) - return receipt - } - - return receiptOrError - -} - - - -// GameMaster.submitProposal(proposalStruct,playerId) { -// gameId,sig,proposal,propId = proposalStruct -// turn = GameContract.ReadState(gameId) -// { -// turn = GameStorage.readState(gameId) -// } -// KeyStore.getTurnSalt(gameId,turn+1) -// { -// turnSalt = hash(PK,gameId,turn+1) -// return nextTurnSalt -// } -// playerSalt = hash(nextTurnSalt,playerId) -// propId = hash(playerSalt,proposal) -// if(playerId != signer(propId,sig)) -// { -// return error -// } -// encrProposal = KeyStore.encrypt(proposal) -// gmSignature= KeyStore.sign(playerId,propId,encrProposal) - -// return _(gmSignature, encdProposal) - -// } \ No newline at end of file diff --git a/docs/uml/VotingSequence.zenuml b/docs/uml/VotingSequence.zenuml deleted file mode 100644 index 1b895993..00000000 --- a/docs/uml/VotingSequence.zenuml +++ /dev/null @@ -1,23 +0,0 @@ - -GameMaster.submitVote(vote,signature) -{ - turn = GameContract.ReadState(game) - if(invalidVote) {return error} - - salt = KeyStore.getPlayerSalt(gameid,turn,playerId) - { - turnSalt = hash(PK,gameId,turn) - playerSalt = hash(turnSalt,playerId) - } - // allows to validate votes against this checksum when salt is revealed - checksum = hash(vote,signature,salt) - encryptedVote = KeyStore.encrypt(vote+playerId) - GameMasterFacet.subitVote(player,encryptedVote,checksum) - { - GameStorage.setVoted(player,checksum) - EventLogs.voted(player,encryptedVote,encrSignature) - return receipt - } - return receipt -} - diff --git a/hardhat.config.ts b/hardhat.config.ts index 2a180735..63b9413d 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -15,6 +15,7 @@ import 'solidity-docgen'; import './playbook/createGame'; import getSuperInterface from './scripts/getSuperInterface'; import { ErrorFragment, EventFragment, FunctionFragment } from '@ethersproject/abi'; +import './scripts/generateSelectorDocs'; task('accounts', 'Prints the list of accounts', async (taskArgs, hre) => { const accounts = await hre.ethers.getSigners(); diff --git a/scripts/diamond.ts b/scripts/diamond.ts index eb2c8106..b86c6b5a 100644 --- a/scripts/diamond.ts +++ b/scripts/diamond.ts @@ -205,7 +205,7 @@ export class DiamondChanges { /** * Presents the Diamond `cut` changeset to the user as a table of - * "added"/"replaces"/"removed" and prompts them to approve the changest. + * "added"/"replaces"/"removed" and prompts them to approve the changeset. * * If they approve the changeset, the returned promise is resolved with `true`, or * `false` if it isn't approved. diff --git a/scripts/generateSelectorDocs.ts b/scripts/generateSelectorDocs.ts new file mode 100644 index 00000000..c7158d57 --- /dev/null +++ b/scripts/generateSelectorDocs.ts @@ -0,0 +1,53 @@ +import { task } from 'hardhat/config'; +import getSuperInterface from './getSuperInterface'; +import fs from 'fs'; +import path from 'path'; +import { FunctionFragment, EventFragment } from '@ethersproject/abi'; + +task('generate-selector-docs', 'Generates markdown documentation for all selectors').setAction(async _ => { + // Get all interfaces + const superInterface = getSuperInterface(); + const fragments = superInterface.fragments; + + // Organize fragments by type + const functions = fragments.filter(f => f.type === 'function') as FunctionFragment[]; + const events = fragments.filter(f => f.type === 'event') as EventFragment[]; + + // Generate markdown content + let markdown = '# Contract Interface Reference\n\n'; + + // Functions section + markdown += '## Functions\n\n'; + markdown += '| Selector | Function | Inputs | Outputs |\n'; + markdown += '|----------|----------|---------|----------|\n'; + + functions.forEach(func => { + const selector = superInterface.getSighash(func); + const name = func.name; + const inputs = func.inputs.map(input => `${input.type} ${input.name}`).join(', '); + const outputs = func.outputs?.map(output => output.type).join(', ') || 'void'; + + markdown += `| \`${selector}\` | ${name} | (${inputs}) | ${outputs} |\n`; + }); + + // Events section + markdown += '\n## Events\n\n'; + markdown += '| Topic | Event | Parameters |\n'; + markdown += '|-------|-------|------------|\n'; + + events.forEach(event => { + const topic = superInterface.getEventTopic(event); + const name = event.name; + const params = event.inputs + .map(input => `${input.type} ${input.indexed ? '(indexed) ' : ''}${input.name}`) + .join(', '); + + markdown += `| \`${topic}\` | ${name} | (${params}) |\n`; + }); + + // Save to docs directory + const docsPath = path.join(__dirname, '../docs/selectors.md'); + fs.writeFileSync(docsPath, markdown); + + console.log(`✅ Selector documentation generated at ${docsPath}`); +}); diff --git a/src/facets/RankifyInstanceGameMastersFacet.sol b/src/facets/RankifyInstanceGameMastersFacet.sol index 7599d9e2..09831bab 100644 --- a/src/facets/RankifyInstanceGameMastersFacet.sol +++ b/src/facets/RankifyInstanceGameMastersFacet.sol @@ -234,7 +234,7 @@ contract RankifyInstanceGameMastersFacet is DiamondReentrancyGuard, EIP712 { game.playerVoted[players[i]] = false; game.votesHidden[players[i]].hash = bytes32(0); } - // This data is to needed to correctly detetermine "PlayerMove" conditions during next turn + // This data is to needed to correctly determine "PlayerMove" conditions during next turn game.numVotesPrevTurn = game.numVotesThisTurn; game.numVotesThisTurn = 0; game.numPrevProposals = game.numCommitments; diff --git a/src/initializers/DiamondInit.sol b/src/initializers/DiamondInit.sol index 18132293..4bdccf23 100644 --- a/src/initializers/DiamondInit.sol +++ b/src/initializers/DiamondInit.sol @@ -16,7 +16,7 @@ import {IERC165} from "../vendor/diamond/interfaces/IERC165.sol"; // It is expected that this contract is customized if you want to deploy your diamond // with data from a deployment script. Use the init function to initialize state variables -// of your diamond. Add parameters to the init funciton if you need to. +// of your diamond. Add parameters to the init function if you need to. contract DiamondInit { // You can add parameters to this function in order to pass in diff --git a/src/libraries/LibCoinVending.sol b/src/libraries/LibCoinVending.sol index 5137287f..2adf655b 100644 --- a/src/libraries/LibCoinVending.sol +++ b/src/libraries/LibCoinVending.sol @@ -160,7 +160,7 @@ library LibCoinVending { * * - The token balances of the `from` and `to` addresses, or the total supply of tokens if `to` is the zero address. */ - function trasferFromAny(address erc20Addr, address from, address to, uint256 value) private { + function transferFromAny(address erc20Addr, address from, address to, uint256 value) private { MockERC20 token = MockERC20(erc20Addr); if (value != 0) { if (from == address(this)) { @@ -201,10 +201,10 @@ library LibCoinVending { address burnAddress, address lockAddress ) private { - trasferFromAny(erc20Addr, from, lockAddress, tokenReq.lock.amount); - trasferFromAny(erc20Addr, from, burnAddress, tokenReq.burn.amount); - trasferFromAny(erc20Addr, from, payee, tokenReq.pay.amount); - trasferFromAny(erc20Addr, from, beneficiary, tokenReq.bet.amount); + transferFromAny(erc20Addr, from, lockAddress, tokenReq.lock.amount); + transferFromAny(erc20Addr, from, burnAddress, tokenReq.burn.amount); + transferFromAny(erc20Addr, from, payee, tokenReq.pay.amount); + transferFromAny(erc20Addr, from, beneficiary, tokenReq.bet.amount); MockERC20 token = MockERC20(erc20Addr); uint256 value = tokenReq.have.amount; if (value != 0 && from != address(this)) { @@ -226,15 +226,15 @@ library LibCoinVending { * * Notes: * - * Due to non fungable nature it's an open question how to implement this method correctly for lock/burn/pay/bet cases. + * Due to non fungible nature it's an open question how to implement this method correctly for lock/burn/pay/bet cases. * In this library I assume that requirements are for multiple members, hence it makes no sense to put requirement on particular tokenId for ERC721. * I think best approach would be to split in to two methods: * 1. fulfillERC72Balance: Treats tokens as fungible - requires one to lock/burn/pay/bet ANY token id, but in total should be equal to desired value. * 2. fulfillERC721Ids: Requires one to lock/burn/pay/bet specific token id. (useful when requirements are unique per applicant). * fulfillERC72Balance is easy. fulfillERC721Ids brings up a question of how to select those ID's(since must specify for ERC721 contract on transfer method). * Two possible solutions: - * 1: modify fund() method to accept array of address+id pairs of NFT's and parse trough it. Compucationaly inefficient. - * 2: implement onERC721Received such that there is NFT vault in the contract, later fill funding position from that vault. That way applicant could pre-send NFT's to the contract and callfing fund later would pull those out from the vault. + * 1: modify fund() method to accept array of address+id pairs of NFT's and parse trough it. computationally inefficient. + * 2: implement onERC721Received such that there is NFT vault in the contract, later fill funding position from that vault. That way applicant could pre-send NFT's to the contract and calling fund later would pull those out from the vault. */ function fulfillERC72Balance(address erc721addr, ContractCondition storage tokenReq, address from) private view { @@ -283,7 +283,6 @@ library LibCoinVending { } value = tokenReq.pay.amount; if (value != 0) { - // token.transfe token.safeTransferFrom(from, payee, id, value, tokenReq.pay.data); } value = tokenReq.bet.amount; @@ -389,7 +388,7 @@ library LibCoinVending { } /** - * @dev Returns all position requirements back to fundee. `position` is the identifier of the condition. `to` is the address to refund the balance to. + * @dev Returns all position requirements back to founder. `position` is the identifier of the condition. `to` is the address to refund the balance to. * * Requirements: * @@ -406,7 +405,7 @@ library LibCoinVending { } /** - * @dev Returns all position requirements back to multiple fundees. `position` is the identifier of the condition. `returnAddresses` is an array of addresses to refund the balance to. + * @dev Returns all position requirements back to multiple founders. `position` is the identifier of the condition. `returnAddresses` is an array of addresses to refund the balance to. * * Requirements: * @@ -473,9 +472,9 @@ library LibCoinVending { } } - function _fund(Condition storage reqPos, address funder) private { + function _fund(Condition storage reqPos, address founder) private { require(reqPos._isConfigured, "Position does not exist"); - fulfill(reqPos, funder, address(this), address(this), address(this), address(this)); + fulfill(reqPos, founder, address(this), address(this), address(this), address(this)); reqPos.timesFunded += 1; } diff --git a/src/libraries/LibQuadraticVoting.sol b/src/libraries/LibQuadraticVoting.sol index 05e4ceaa..19325db9 100644 --- a/src/libraries/LibQuadraticVoting.sol +++ b/src/libraries/LibQuadraticVoting.sol @@ -16,7 +16,7 @@ library LibQuadraticVoting { } /** - * @dev Precomputes the values for quadratic voting. `voteCredits` is the total number of vote credits. `minExpectedVoteItems` is the minimum expected number of vote items. + * @dev Pre-computes the values for quadratic voting. `voteCredits` is the total number of vote credits. `minExpectedVoteItems` is the minimum expected number of vote items. * * Returns: * @@ -37,10 +37,10 @@ library LibQuadraticVoting { accumulator += (q.maxQuadraticPoints - iterator) ** 2; iterator++; } while (accumulator < voteCredits); - // This enforces requirement that all vote credits can indeed be spended (no leftovers) + // This enforces requirement that all vote credits can indeed be spent (no leftovers) if (accumulator != voteCredits) require(false, "quadraticVotingError: voteCredits bust be i^2 series"); //revert quadraticVotingError("voteCredits bust be i^2 series", accumulator, voteCredits); q.minQuadraticPositions = iterator; - // In order to spend all vote credits there must be at least minQuadraticPositions+1 (becuase proposer is also a player and cannot vote for himself) + // In order to spend all vote credits there must be at least minQuadraticPositions+1 (because proposer is also a player and cannot vote for himself) if (minExpectedVoteItems <= q.minQuadraticPositions) require(false, "quadraticVotingError: Minimum Voting positions above min players"); // revert quadraticVotingError( @@ -53,7 +53,7 @@ library LibQuadraticVoting { } /** - * @dev Computes the scores for each proposal by voter preference index. `q` is the precomputed quadratic voting values. `VotersVotes` is a 2D array of votes, where each row corresponds to a voter and each column corresponds to a proposal. `isActive` is an array indicating whether each voter has voted. `notVotedGivesEveyone` is the number of points to distribute to each proposal for each voter that did not vote. `proposalsLength` is the number of proposals. + * @dev Computes the scores for each proposal by voter preference index. `q` is the precomputed quadratic voting values. `VotersVotes` is a 2D array of votes, where each row corresponds to a voter and each column corresponds to a proposal. `isActive` is an array indicating whether each voter has voted. * * Returns: * diff --git a/src/libraries/LibRankify.sol b/src/libraries/LibRankify.sol index 5b464f73..7972e1a1 100644 --- a/src/libraries/LibRankify.sol +++ b/src/libraries/LibRankify.sol @@ -379,7 +379,7 @@ library LibRankify { * - Calls `onPlayerLeftCallback` for `player`. */ function quitGame(uint256 gameId, address player, function(uint256, address) onPlayerLeftCallback) internal { - removeAndUnlockPlayer(gameId, player); // this will throw if game has started or doesnt exist + removeAndUnlockPlayer(gameId, player); // this will throw if game has started or doesn't exist onPlayerLeftCallback(gameId, player); } @@ -401,7 +401,7 @@ library LibRankify { // Cancel the game for each player address[] memory players = gameId.getPlayers(); for (uint256 i = 0; i < players.length; ++i) { - quitGame(gameId, players[i], onPlayerLeftCallback); //this will throw if game has started or doesnt exist + quitGame(gameId, players[i], onPlayerLeftCallback); //this will throw if game has started or doesn't exist } // Delete the game @@ -424,7 +424,7 @@ library LibRankify { } /** - * @dev Emits rank rewards to the top three addresses in the leaderboard. `gameId` is the ID of the game. `leaderboard` is an array of addresses representing the leaderboard sorted in descendign order. `rankTokenAddress` is the address of the rank token contract. + * @dev Emits rank rewards to the top three addresses in the leaderboard. `gameId` is the ID of the game. `leaderboard` is an array of addresses representing the leaderboard sorted in descending order. `rankTokenAddress` is the address of the rank token contract. * * Modifies: * @@ -503,8 +503,8 @@ library LibRankify { GameState storage game = getGameState(gameId); bool expectVote = true; bool expectProposal = true; - if (turn == 1) expectVote = false; //Dont expect votes at firt turn - // else if (gameId.isLastTurn()) expectProposal = false; // For now easiest solution is to keep collecting proposals as that is less complicated boundry case + if (turn == 1) expectVote = false; // Don't expect votes at first turn + // else if (gameId.isLastTurn()) expectProposal = false; // For now easiest solution is to keep collecting proposals as that is less complicated boundary case if (game.numPrevProposals < game.voting.minQuadraticPositions) expectVote = false; // If there is not enough proposals then round is skipped votes cannot be filled bool madeMove = true; if (expectVote && !game.playerVoted[player]) madeMove = false; diff --git a/src/libraries/LibReentrancyGuard.sol b/src/libraries/LibReentrancyGuard.sol index 130a9448..ae316f58 100644 --- a/src/libraries/LibReentrancyGuard.sol +++ b/src/libraries/LibReentrancyGuard.sol @@ -7,7 +7,7 @@ import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; library LibReentrancyGuard { - bytes32 constant TBG_STORAGE_POSITION = keccak256("reentrancyguard.storage.position"); + bytes32 constant TBG_STORAGE_POSITION = keccak256("reentrancy.guard.storage.position"); struct ReentrancyGuardStruct { bool _entered; diff --git a/src/libraries/LibTurnBasedGame.sol b/src/libraries/LibTurnBasedGame.sol index c6a448c1..eb1c782a 100644 --- a/src/libraries/LibTurnBasedGame.sol +++ b/src/libraries/LibTurnBasedGame.sol @@ -22,7 +22,7 @@ import {IErrors} from "../interfaces/IErrors.sol"; * * ***WARNING*** Some limitations: * - This library is still under development and its interfaces may change. - * - getting game data (which has own storage assigement and can be encapsulated from library) however there is no storage slot collision checks in place + * - getting game data (which has own storage assignment and can be encapsulated from library) however there is no storage slot collision checks in place * */ library LibTBG { @@ -359,7 +359,7 @@ library LibTBG { * - The current turn in the game with `gameId` must be able to end. */ modifier onlyInTurnTime(uint256 gameId) { - require(isTurnTimedOut(gameId) == false, "onlyInTurnTime -> turn timedout"); + require(isTurnTimedOut(gameId) == false, "onlyInTurnTime -> turn timeout"); _; } diff --git a/utils/multipass.ts b/utils/multipass.ts deleted file mode 100644 index 749b825d..00000000 --- a/utils/multipass.ts +++ /dev/null @@ -1,226 +0,0 @@ -import { ethers, BigNumber, Wallet, BytesLike } from 'ethers'; -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; -import { LibMultipass } from '../types/src/facets/DNSFacet'; -export enum SearchCriteria { - id, - username, - address, -} -export interface SignerIdentity { - name: string; - id: string; - wallet: Wallet | SignerWithAddress; -} -interface ReferrerMesage { - referrerAddress: string; -} -interface RegisterMessage { - name: BytesLike; - id: BytesLike; - domainName: BytesLike; - deadline: BigNumber; - nonce: BigNumber; -} - -type signatureMessage = ReferrerMesage | RegisterMessage; - -export class MultipassJs { - // private JsonRpcProvider; - private chainId; - private name; - private version; - constructor({ chainId, contractName, version }: { chainId: any; contractName: string; version: string }) { - // if (!ProviderNetwork) throw new Error("Provider network not defined"); - // this.JsonRpcProvider = new ethers.providers.BaseProvider(ProviderNetwork); - this.chainId = chainId; - this.name = contractName; - this.version = version; - } - public getDappURL( - message: any, - signature: string, - // type: string, - basepath: string, - contractAddress: string, - domain: string, - ) { - return ( - basepath + - '/?message=' + - Buffer.from(JSON.stringify(message)).toString('base64') + - '&contractAddress=' + - contractAddress + - '&signature=' + - signature + - '&chainId=' + - this.chainId - ); - } - public signRegistrarMessage = async ( - message: RegisterMessage, - verifierAddress: string, - signer: Wallet | SignerWithAddress, - ) => { - let chainId = this.chainId; - - const domain = { - name: this.name, - version: this.version, - chainId, - verifyingContract: verifierAddress, - }; - - const types = { - registerName: [ - { - type: 'bytes32', - name: 'name', - }, - { - type: 'bytes32', - name: 'id', - }, - { - type: 'bytes32', - name: 'domainName', - }, - { - type: 'uint256', - name: 'deadline', - }, - { - type: 'uint96', - name: 'nonce', - }, - ], - }; - - const s = await signer._signTypedData(domain, types, { ...message }); - return s; - }; - - public getRegistrarMessage = ({ - username, - id, - domainName, - validUntil, - }: { - username: string; - id: string; - domainName: string; - validUntil: number; - }) => { - const registrarMessage = { - name: ethers.utils.formatBytes32String(username), - id: ethers.utils.formatBytes32String(id), - domainName: ethers.utils.formatBytes32String(domainName), - deadline: ethers.BigNumber.from(validUntil), - nonce: ethers.BigNumber.from(0), - }; - - return registrarMessage; - }; - - public formQueryByAddress = ({ - address, - domainName, - targetDomain, - }: { - address: string; - targetDomain?: string; - domainName: string; - }) => { - if (!ethers.utils.isAddress(address)) throw new Error('formQueryByAddress: is not a valid address'); - const query: LibMultipass.NameQueryStruct = { - name: ethers.utils.formatBytes32String(''), - id: ethers.utils.formatBytes32String(''), - wallet: address, - domainName: ethers.utils.formatBytes32String(domainName), - targetDomain: targetDomain ?? ethers.utils.formatBytes32String(''), - }; - return query; - }; - - public formQueryById = ({ - id, - domainName, - targetDomain, - }: { - id: string; - targetDomain?: string; - domainName: string; - }) => { - const query: LibMultipass.NameQueryStruct = { - name: ethers.utils.formatBytes32String(''), - id: ethers.utils.formatBytes32String(id), - wallet: ethers.constants.AddressZero, - domainName: ethers.utils.formatBytes32String(domainName), - targetDomain: targetDomain ?? ethers.utils.formatBytes32String(''), - }; - return query; - }; - - public formQueryByUsername = ({ - username, - domainName, - targetDomain, - }: { - username: string; - targetDomain?: string; - domainName: string; - }) => { - const query: LibMultipass.NameQueryStruct = { - name: ethers.utils.formatBytes32String(username), - id: ethers.utils.formatBytes32String(''), - wallet: ethers.constants.AddressZero, - domainName: ethers.utils.formatBytes32String(domainName), - targetDomain: targetDomain ?? ethers.utils.formatBytes32String(''), - }; - return query; - }; - - public formQueryByUsernameAndId = ({ - username, - domainName, - targetDomain, - id, - }: { - username: string; - targetDomain?: string; - domainName: string; - id: string; - }) => { - const query: LibMultipass.NameQueryStruct = { - name: ethers.utils.formatBytes32String(username), - id: ethers.utils.formatBytes32String(id), - wallet: ethers.constants.AddressZero, - domainName: ethers.utils.formatBytes32String(domainName), - targetDomain: targetDomain ?? ethers.utils.formatBytes32String(''), - }; - return query; - }; - - public formQueryByFullDetails = ({ - username, - domainName, - targetDomain, - id, - address, - }: { - username: string; - targetDomain?: string; - domainName: string; - id: string; - address: string; - }) => { - if (!ethers.utils.isAddress(address)) throw new Error('formQueryByAddress: is not a valid address'); - const query: LibMultipass.NameQueryStruct = { - name: ethers.utils.formatBytes32String(username), - id: ethers.utils.formatBytes32String(id), - wallet: address, - domainName: ethers.utils.formatBytes32String(domainName), - targetDomain: targetDomain ?? ethers.utils.formatBytes32String(''), - }; - return query; - }; -}