graphprotocol / graphprotocol/graph-node

Automatically lower-case address inputs

Aperta
#3,890 3 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Stale
Lingua principale
Rust
Stelle
3.2k
Fork
1.1k
Merge medio
4g 1h
PR unite (30g)
1

Descrizione

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.

{
  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 ID or Bytes. /^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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Parti dal comportamento della query GraphQL mostrato per il campo id di accounts e confronta gli indirizzi con checksum o in maiuscolo con la query in minuscolo. Determina se la normalizzazione debba essere applicata a Bytes, a ID o a entrambi, e definisci il comportamento di fallback previsto prima di implementare e testare il risultato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
graphql, rust
Ambito
api, backend-api-design
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.