feat(indexer): イベントインデックスを拡充 (AllowList / ERC20 Transfer / 累計納税額)#109
feat(indexer): イベントインデックスを拡充 (AllowList / ERC20 Transfer / 累計納税額)#109
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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.
| 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; | ||
| } |
There was a problem hiding this comment.
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".
| @@ -83,8 +112,13 @@ type Query { | |||
| distributionRatios(first: Int, skip: Int, orderBy: DistributionRatio_orderBy, orderDirection: OrderDirection): [DistributionRatio!]! | |||
| } | |||
There was a problem hiding this comment.
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.
関連 Issue
Closes #96
Closes #97
Closes #98
Closes #99
変更内容
FoR サブグラフに以下 4 つの拡張をまとめて追加し、sepolia 環境 (
for-sepolia/0.0.0) に再デプロイ済み。AllowListAdded/AllowListRemovedを処理。AllowedUserエンティティで現在の許可状態を管理し、allowedUsersクエリを提供。Transfer→TransferViaRouterリネーム: ERC20 標準 Transfer との名前衝突を避け、Router 経由の分配送金を表す既存エンティティをリネーム。Userの derivedFrom フィールドもsentTransfersViaRouter/receivedTransfersViaRouter/executedTransfersViaRouterに更新。フロントエンドの GraphQL クエリ・フック (useTransfersViaRouter) も追従。Transferイベントのインデックス: FoRToken dataSource にTransfer(indexed address,indexed address,uint256)ハンドラーを追加。Router 経由でない純粋な移転も含めた全送金履歴をtransfersクエリで取得可能に。Router 経由の送金と同一transactionHashで並存する。fundAmount+burnAmount) を「納税」としてUserエンティティに累計。totalTaxPaid/totalFundTaxPaid/totalBurnTaxPaidをhandleTransferWithDistribution内で送金元 (from) に加算更新。その他
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) 成功hasIndexingErrors: false、100% 同期確認TransferViaRouterに 1 件 (fund1,500/ burn500/ recipient8,000) が記録Transfer3 件 (fund / burn / recipient) がtransfersに記録totalTaxPaidが2,000 FOR(fund1,500+ burn500) に加算AllowedUserに BURN_ADDRESS を含む 3 件が記録その他
mustacheで生成されるため追跡対象外 (.gitignore)。テンプレートsubgraph.template.yamlのみ更新。