Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

83 0100 developer docs #85

Merged
merged 7 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/hungry-doors-beam.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions: {}
env:
env:
FORK_RPC_URL: ${{ secrets.FORK_RPC_URL }}
jobs:
release:
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,5 @@ bin/
/deployments/hardhat/

abi/
docs/contracts/
docs/contracts/
docs/selectors.md
40 changes: 0 additions & 40 deletions docs/gm.mdx

This file was deleted.

51 changes: 0 additions & 51 deletions docs/uml/EndTurnSequence.zenuml

This file was deleted.

26 changes: 0 additions & 26 deletions docs/uml/GMHandShake.zenuml

This file was deleted.

14 changes: 0 additions & 14 deletions docs/uml/GovernanceRoadmap.zenuml

This file was deleted.

28 changes: 0 additions & 28 deletions docs/uml/OverviewSequence.zenuml

This file was deleted.

72 changes: 0 additions & 72 deletions docs/uml/ProposingSequence.zenuml

This file was deleted.

23 changes: 0 additions & 23 deletions docs/uml/VotingSequence.zenuml

This file was deleted.

1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion scripts/diamond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
53 changes: 53 additions & 0 deletions scripts/generateSelectorDocs.ts
Original file line number Diff line number Diff line change
@@ -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}`);
});
2 changes: 1 addition & 1 deletion src/facets/RankifyInstanceGameMastersFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/initializers/DiamondInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading