graphprotocol / graphprotocol/graph-node
Automatically lower-case address inputs
まだ誰も着手していません。
- 主要言語
- Rust
- スター
- 3.2k
- フォーク
- 1.1k
- 平均マージ
- 4日 1時間
- マージ済み PR(30日)
- 1
説明
Do you want to request a feature or report a bug?
Both?
What is the current behavior?
A common pitfall for new users of The Graph is the ID or a Bytes fields actually contain an Ethereum address. When trying to query for that address with EIP-55 checksummed mixed-case strings or upper-case strings there is no match. Without further knowledge of the inner workings of the graph-node, this is a break in the developer journey. For example: "I know this address has a Punk but the subgraph does not show it. So it must be broken"
If the current behaviour is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
- Open a Subgraph, for example: https://thegraph.com/hosted-service/subgraph/itsjerryokolo/cryptopunks
- Send a query with checksummed address:
{
accounts(where: {id: "0xF22F00D0B95B1b728078066E5f4410F6B2Be8faE"}) {
averageAmountSpent
id
}
}
What is the expected behavior?
Same as when sending this query to the above subgraph:
{
accounts(where: {id: "0xf22f00d0b95b1b728078066e5f4410f6b2be8fae"}) {
averageAmountSpent
id
}
}
Proposed steps
Since we don't know from the schema if an ID or Bytes field actually does contain an Ethereum address, I propose to do the following steps:
- Check if the input string is an Ethereum address and the queried field is
IDorBytes./^0x[a-fA-F0-9]{40}$/ - For
Bytes: Lowercase the input string before sending to the database - For
ID: (This is a bit tricky): Maybe try to send the query and if it is null, resend it with lower-cased input?
Remarks
The possible solution here is good for backwards compatibility of subgraphs and probably easy to implement. A better long-term solution would be the introduction of an Address scalar type.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
accounts の id フィールドについて示されている GraphQL クエリの動作を出発点とし、チェックサム付きまたは大文字のアドレスと小文字のクエリを比較します。正規化を Bytes、ID、またはその両方に適用すべきかを判断し、結果を実装してテストする前に、期待されるフォールバック動作を定義します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- graphql, rust
- 領域
- api, backend-api-design
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100