Skip to content
Open
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
3 changes: 0 additions & 3 deletions .vscode/extensions.json

This file was deleted.

12 changes: 0 additions & 12 deletions .vscode/settings.json

This file was deleted.

40 changes: 40 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Repository Guidelines

## Project Structure & Module Organization
This repo is a pnpm-managed monorepo with two workspaces under `packages/`.
- `packages/contract/`: Hardhat-based smart contracts, Solidity sources in `packages/contract/contracts/` and tests alongside as `*.t.sol`.
- `packages/frontend/`: React Router v7 app (Vite + Tailwind) with server/client build output in `packages/frontend/build/`.
- Root config: `pnpm-workspace.yaml`, `biome.json`, and shared toolchain settings.

## Build, Test, and Development Commands
Run these from the repo root unless noted.
- `pnpm install`: install workspace dependencies.
- `pnpm build`: build all packages (as defined in each workspace).
- `pnpm dev`: run dev servers for all packages that define it.
- `pnpm --filter contract build`: compile contracts.
- `pnpm --filter contract test`: run Hardhat tests (Solidity + node:test).
- `pnpm --filter frontend dev`: start the React Router dev server.
- `pnpm --filter frontend build`: produce production build artifacts.
- `pnpm --filter frontend typegen`: generate React Router types.

## Coding Style & Naming Conventions
- Formatting/linting: Biome is the standard (`biome.json`), 2-space indentation.
- TypeScript: prefer explicit types over `any`.
- Solidity: keep tests colocated with contracts and use `*.t.sol` naming (Foundry-compatible).
- File names: use descriptive, domain-aligned names (e.g., `RouterFactory.sol`).

## Testing Guidelines
- Smart contract tests run via Hardhat: `pnpm --filter contract test`.
- Solidity tests live in `packages/contract/contracts/*.t.sol`.
- Node.js integration tests (if present) also run through `hardhat test`.
- For frontend, run `pnpm --filter frontend typegen` as part of change verification.

## Commit & Pull Request Guidelines
- Use Conventional Commit-style messages seen in history: `feat:`, `chore:`, `fix:`, etc.
- PRs should reference a related Issue (`#123`) and include a clear summary of changes.
- Create Issues before PRs; single, standalone PRs are not accepted.
- Consider Draft PRs for work-in-progress and include screenshots for UI changes.

## Communication & Conduct
- Coordination happens in the Hackdays Discord; prefer Issue comments for questions tied to work.
- Follow the Code for Japan code of conduct linked in `CONTRIBUTING.md`.
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ FORトークンを送金するたびに、自動的に以下へ分配されま
FoR/
├── packages/
│ ├── contract/ # スマートコントラクト (Hardhat)
│ └── frontend/ # Webアプリケーション (React Router)
│ ├── frontend/ # Webアプリケーション (React Router)
│ └── indexer/ # Goldsky サブグラフ/インデクサー
└── pnpm-workspace.yaml
```

Expand All @@ -60,6 +61,12 @@ FoR/
- **Vite**: ビルドツール
- **TypeScript**: 型安全な開発

### インデクサー

- **Goldsky**: Subgraphホスティング
- **Graph Protocol (AssemblyScript)**: イベントマッピング
- **GraphQL**: インデックス済みデータ取得

## 🚀 セットアップ

### 環境要件
Expand All @@ -73,11 +80,11 @@ FoR/
# 依存関係のインストール
pnpm install

# 全パッケージのビルド
pnpm build
# コントラクトのビルド
pnpm --filter contract build

# 開発サーバー起動
pnpm dev
# フロントエンドの開発サーバー起動
pnpm --filter frontend dev
```

### パッケージ別コマンド
Expand Down Expand Up @@ -112,6 +119,25 @@ pnpm build
pnpm typecheck
```

#### インデクサー (packages/indexer/)

```bash
cd packages/indexer

# codegen
pnpm codegen

# サブグラフのビルド
pnpm build

# Sepoliaへのデプロイ
pnpm deploy:sepolia
```

### Indexer Endpoint

- Sepolia GraphQL endpoint: `<set-after-deploy>`

## 📚 ドキュメント

- [開発ガイド](./CLAUDE.md) - 開発の詳細な情報
Expand Down
78 changes: 42 additions & 36 deletions packages/contract/README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,63 @@
# Sample Hardhat 3 Beta Project (`node:test` and `viem`)
# FoR Contract

This project showcases a Hardhat 3 Beta project using the native Node.js test runner (`node:test`) and the `viem` library for Ethereum interactions.
FoR のスマートコントラクトパッケージです(Hardhat v3 / Ignition)。

To learn more about the Hardhat 3 Beta, please visit the [Getting Started guide](https://hardhat.org/docs/getting-started#getting-started-with-hardhat-3). To share your feedback, join our [Hardhat 3 Beta](https://hardhat.org/hardhat3-beta-telegram-group) Telegram group or [open an issue](https://github.com/NomicFoundation/hardhat/issues/new) in our GitHub issue tracker.
## 必要な環境変数

## Project Overview
Sepolia へデプロイする場合のみ、実行時に以下を設定します。

This example project includes:
- `SEPOLIA_RPC_URL`
- `SEPOLIA_PRIVATE_KEY`(`0x` + 64桁hex)

- A simple Hardhat configuration file.
- Foundry-compatible Solidity unit tests.
- TypeScript integration tests using [`node:test`](nodejs.org/api/test.html), the new Node.js native test runner, and [`viem`](https://viem.sh/).
- Examples demonstrating how to connect to different types of networks, including locally simulating OP mainnet.
## 開発コマンド

## Usage

### Running Tests

To run all the tests in the project, execute the following command:

```shell
npx hardhat test
```bash
pnpm --filter @for/contract build
pnpm --filter @for/contract test
pnpm --filter @for/contract dev
```

You can also selectively run the Solidity or `node:test` tests:
## デプロイコマンド

```shell
npx hardhat test solidity
npx hardhat test nodejs
```bash
pnpm --filter @for/contract deploy:local:FoRToken
pnpm --filter @for/contract deploy:local:RouterFactory
pnpm --filter @for/contract deploy:local:Router
pnpm --filter @for/contract deploy:sepolia:FoRToken
pnpm --filter @for/contract deploy:sepolia:RouterFactory
pnpm --filter @for/contract deploy:sepolia:Router
```

### Make a deployment to Sepolia
## Sepolia への推奨手順

This project includes an example Ignition module to deploy the contract. You can deploy this module to a locally simulated chain or to Sepolia.
`Router` モジュール実行で依存する `FoRToken` / `RouterFactory` も一緒に処理されます。

To run the deployment to a local chain:
```bash
export SEPOLIA_RPC_URL="..."
export SEPOLIA_PRIVATE_KEY="0x..."
pnpm --filter @for/contract deploy:sepolia:Router
```

```shell
npx hardhat ignition deploy ignition/modules/Counter.ts
過去の Ignition state と不整合がある場合は `--reset` を使います。

```bash
pnpm --filter @for/contract exec hardhat ignition deploy \
ignition/modules/Router.ts \
--network sepolia \
--parameters ignition/parameters.sepolia.json \
--reset
```

To run the deployment to Sepolia, you need an account with funds to send the transaction. The provided Hardhat configuration includes a Configuration Variable called `SEPOLIA_PRIVATE_KEY`, which you can use to set the private key of the account you want to use.
## デプロイ結果の確認

You can set the `SEPOLIA_PRIVATE_KEY` variable using the `hardhat-keystore` plugin or by setting it as an environment variable.
成果物:

To set the `SEPOLIA_PRIVATE_KEY` config variable using `hardhat-keystore`:
- `packages/contract/ignition/deployments/chain-11155111/deployed_addresses.json`
- `packages/contract/ignition/deployments/chain-11155111/journal.jsonl`

```shell
npx hardhat keystore set SEPOLIA_PRIVATE_KEY
```
参照方法:

After setting the variable, you can run the deployment with the Sepolia network:
- `deployed_addresses.json`: `FoRToken` / `RouterFactory` のアドレス
- `journal.jsonl`: `RouterModule#RouterFactoryModule~RouterFactory.deploy` の `TRANSACTION_CONFIRM` から `Router` の実アドレスと `blockNumber`(=`startBlock`)

```shell
npx hardhat ignition deploy --network sepolia ignition/modules/Counter.ts
```
`Router address` と `startBlock` は `packages/indexer/config/sepolia.json` に反映して、indexer 側デプロイで利用します。
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.28;

import {Test} from "forge-std/Test.sol";
import {FoRToken} from "./FORToken.sol";
import {FoRToken} from "./FoRToken.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";

contract FoRTokenTest is Test {
Expand Down
26 changes: 26 additions & 0 deletions packages/contract/contracts/Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ contract Router is AccessControl, Pausable, ReentrancyGuard {
uint256 recipientAmount
);

/**
* @notice 分配比率が更新された際に発行されるイベント
* @param changedBy 比率を更新したアドレス
* @param fundRatio 更新後の基金への分配比率
* @param burnRatio 更新後のBurnへの分配比率
* @param recipientRatio 更新後の受取人への分配比率
*/
event DistributionRatioUpdated(
address indexed changedBy,
uint256 fundRatio,
uint256 burnRatio,
uint256 recipientRatio
);

/**
* @dev コンストラクタ
* @param _initialAdmin 初期管理者アドレス(全ロールを付与)
Expand Down Expand Up @@ -97,6 +111,12 @@ contract Router is AccessControl, Pausable, ReentrancyGuard {
) external onlyRole(RATIO_MANAGER_ROLE) whenNotPaused {
require(_fundRatio + burnRatio <= 10000, "Total ratio exceeds 100%");
fundRatio = _fundRatio;
emit DistributionRatioUpdated(
msg.sender,
fundRatio,
burnRatio,
10000 - fundRatio - burnRatio
);
}

/**
Expand All @@ -108,6 +128,12 @@ contract Router is AccessControl, Pausable, ReentrancyGuard {
) external onlyRole(RATIO_MANAGER_ROLE) whenNotPaused {
require(fundRatio + _burnRatio <= 10000, "Total ratio exceeds 100%");
burnRatio = _burnRatio;
emit DistributionRatioUpdated(
msg.sender,
fundRatio,
burnRatio,
10000 - fundRatio - burnRatio
);
}

/**
Expand Down
Loading