Skip to content

feat(indexer): イベントインデックスを拡充 (AllowList / ERC20 Transfer / 累計納税額)#109

Open
aowheel wants to merge 5 commits intomainfrom
feat/indexer-events-bundle
Open

feat(indexer): イベントインデックスを拡充 (AllowList / ERC20 Transfer / 累計納税額)#109
aowheel wants to merge 5 commits intomainfrom
feat/indexer-events-bundle

Conversation

@aowheel
Copy link
Copy Markdown
Collaborator

@aowheel aowheel commented Apr 13, 2026

関連 Issue

Closes #96
Closes #97
Closes #98
Closes #99

変更内容

FoR サブグラフに以下 4 つの拡張をまとめて追加し、sepolia 環境 (for-sepolia/0.0.0) に再デプロイ済み。

その他

  • 破壊的スキーマ変更のため既存 for-sepolia/0.0.1 を破棄、for-sepolia/0.0.0 として再デプロイし latest タグを付け替え。packages/frontend/app/lib/subgraph.ts / .env.example / README / package.json の参照を 0.0.0 に揃えた。

動作確認

  • pnpm build:sepolia (indexer) 成功
  • pnpm codegen + tsc --noEmit (frontend) 成功
  • sepolia にデプロイ → hasIndexingErrors: false、100% 同期確認
  • Router 経由で 10,000 FOR を yuki に送金するスクリプトを実行し、以下を確認:
    • TransferViaRouter に 1 件 (fund 1,500 / burn 500 / recipient 8,000) が記録
    • 同 tx 内の ERC20 Transfer 3 件 (fund / burn / recipient) が transfers に記録
    • 送金元の totalTaxPaid2,000 FOR (fund 1,500 + burn 500) に加算
    • AllowedUser に BURN_ADDRESS を含む 3 件が記録

その他

aowheel and others added 5 commits April 13, 2026 21:50
FoRTokenコントラクトをdataSourceとして追加し、AllowListAdded /
AllowListRemovedイベントをインデックス可能にする。AllowedUserエンティティ
でisAllowedフラグを管理し、allowedUsersクエリで現在の許可済みユーザー
一覧を取得できるようにする (closes #96)。

- config/*.json: address/startBlock を router* にリネームし
  forTokenAddress / forTokenStartBlock を追加
- subgraph.template.yaml: FoRToken dataSource を追加
- schema.graphql: AllowedUser エンティティを追加
- src/mapping.ts: handleAllowListAdded / handleAllowListRemoved 実装

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ERC20 Transfer イベントのインデックス追加に備えて、Router 経由の分配送金を
表す Transfer エンティティを TransferViaRouter にリネーム。User の
derivedFrom フィールドも *ViaRouter に更新し、フロントエンドのクエリも
対応した。

Closes #97

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
FoRToken の ERC20 標準 Transfer イベントをインデックスし、Router を
経由しないトークン移転も含めた全送金履歴を取得可能にした。Router
経由の分配送金は TransferViaRouter に残しつつ、独立した Transfer
エンティティとして管理する。

Closes #98

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Router 経由の分配送金で基金・Burn に自動分配される額を「納税」として
User エンティティに累計する。送金元 (from) ユーザーに対し
totalFundTaxPaid / totalBurnTaxPaid / totalTaxPaid を加算更新する。

Closes #99

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
破壊的スキーマ変更 (TransferViaRouter リネーム、ERC20 Transfer 追加、
累計納税額追加) に伴い、既存 for-sepolia/0.0.1 を破棄して 0.0.0 として
再デプロイ。参照側のエンドポイントも 0.0.0 に揃える。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 13, 2026 13:41
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
for Ready Ready Preview, Comment Apr 13, 2026 1:41pm

Request Review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

FoR サブグラフ(indexer)を拡張し、AllowList イベント / ERC20 Transfer イベントの追加インデックスと、Router 経由送金(旧 Transfer)の TransferViaRouter へのリネーム、および累計納税額(fund+burn)の集計を提供する PR です。合わせて sepolia のサブグラフ参照バージョンを 0.0.0 に揃えています。

Changes:

  • Transfer(Router 経由)を TransferViaRouter にリネームし、フロントのクエリ/フックも追従
  • FoRToken を dataSource に追加し、AllowList(Added/Removed)と ERC20 Transfer をインデックス
  • Router 経由送金時に User.totalTaxPaid(fund/burn 内訳含む)を累計更新

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/indexer/subgraph.template.yaml Router/FoRToken の2 dataSource 構成にし、各イベントハンドラと entity を追加/更新
packages/indexer/src/mapping.ts AllowList・ERC20 Transfer ハンドラ追加、TransferViaRouter への移行、累計納税額の集計ロジック追加
packages/indexer/schema.graphql TransferViaRouter へのリネーム、新 Transfer(ERC20)/ AllowedUser / tax 集計フィールド追加
packages/indexer/README.md 公開エンドポイントを 0.0.0 に更新
packages/indexer/package.json sepolia デプロイ先を for-sepolia/0.0.0 に更新
packages/indexer/config/sepolia.json mustache 変数を router/forToken に分離し、FoRToken の address/startBlock を追加
packages/indexer/config/localhost.json mustache 変数を router/forToken に分離
packages/indexer/config/base.json mustache 変数を router/forToken に分離
packages/frontend/schema.graphql TransferViaRouter 追加・既存 Transfer を ERC20 用に再定義、User フィールドを更新
packages/frontend/app/lib/subgraph.ts sepolia の参照サブグラフ URL を 0.0.0 に更新
packages/frontend/app/hooks/useTransfersViaRouter.ts transferViaRouters を取得する新フック追加
packages/frontend/app/hooks/useTransfers.ts 旧 transfers フック削除
packages/frontend/app/graphql/queries.ts transferViaRouters クエリに更新、User の derived フィールド名変更に追従
packages/frontend/.env.example sepolia サブグラフ URL を 0.0.0 に更新

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +34 to +44
function upsertAllowedUser(
account: string,
isAllowed: boolean,
event: ethereum.Event,
): void {
let allowed = AllowedUser.load(account);
if (allowed == null) {
allowed = new AllowedUser(account);
allowed.addedAtBlock = event.block.number;
allowed.addedAtTimestamp = event.block.timestamp;
}
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upsertAllowedUser initializes addedAtBlock/addedAtTimestamp whenever the entity is first seen, even when invoked from handleAllowListRemoved. If the first observed event for an account is a removal (e.g., indexing starts after the original add), this will incorrectly record the removal time as the "addedAt" time. Consider only setting addedAt* when processing AllowListAdded, and for removals with no prior record either (a) avoid creating a record, or (b) make addedAt* nullable / set to a sentinel value to represent "unknown".

Copilot uses AI. Check for mistakes.
Comment on lines 104 to 113
@@ -83,8 +112,13 @@ type Query {
distributionRatios(first: Int, skip: Int, orderBy: DistributionRatio_orderBy, orderDirection: OrderDirection): [DistributionRatio!]!
}
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frontend schema mirror is missing the new AllowedUser type and the allowedUser/allowedUsers query fields (and any needed filter/orderBy inputs). Since this PR introduces the AllowedUser entity and mentions exposing an allowedUsers query, keeping packages/frontend/schema.graphql in sync will be necessary for typed queries/codegen when the frontend starts consuming AllowList data.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants