ODIS page: update the WalletKeySigner example for @celo/identity 6.0

Aperta
#2,365 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
documentation

Direzione di ricerca

Start with tooling/libraries-sdks/contractkit/odis.mdx, especially lines 41-48, and compare the example with the social-connect README, lib/odis/query.d.ts, and .changeset/nasty-forks-tell.md. Wait until @celo/identity 6.0.0 is the npm latest release, then verify the page against the stable types; done means the WalletKeySigner example and version wording match 6.0 and the remaining examples still work.

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

Descrizione

The WalletKeySigner example in tooling/libraries-sdks/contractkit/odis.mdx (prose on line 41, code on lines 43-48) uses the @celo/identity 5.x API. It does not work with 6.0.

The example passes a ContractKit instance:

const authSigner: AuthSigner = {
  authenticationMethod: OdisUtils.Query.AuthenticationMethod.WALLET_KEY,
  contractKit,
};

In 6.0, WalletKeySigner has no contractKit field. It takes a sign191 function that signs the message with EIP-191 and returns the signature. From lib/odis/query.d.ts in 6.0.0-beta.0:

export interface WalletKeySigner {
    authenticationMethod: AuthenticationMethod.WALLET_KEY;
    sign191: ({ message, account }: { message: SignableMessage; account: Address }) => Promise<Hex>;
}

The types come from viem, and @celo/contractkit is now an optional peer dependency. The social-connect changeset .changeset/nasty-forks-tell.md describes the change, and the social-connect README uses the new form:

const authSigner: AuthSigner = {
  authenticationMethod: OdisUtils.Query.AuthenticationMethod.WALLET_KEY,
  sign191: ({ message, account }) => viemClient.signMessage({ message, account }),
};

Copied into a 6.0 project, the current example fails to type-check. Plain JavaScript gets further and then fails when the library calls signer.sign191. The sentence on line 41 ("passing in a contractkit instance with the account unlocked") is wrong for 6.0 too. The EncryptionKeySigner example on lines 34-39 works in both versions.

This can't change yet. npm latest is still 5.1.2, and 6.0 is published only as 6.0.0-beta.0 under the beta tag, so switching the example now would break it for everyone on the stable release. #2346 left it alone for that reason, although the page already says the Celo Sepolia contexts need 6.0.0-beta.0 or later.

When @celo/identity 6.0.0 ships as latest:

  • Replace the contractKit example with the sign191 form and rewrite line 41 to match.
  • Check the rest of the page against the 6.0 types. The changeset says many fields that were string are now 0x-string typed.
  • Change "6.0.0-beta.0 and later" to the stable version.
Lingua principale
MDX
Stelle
90
Fork
398
Merge medio
4g 22h
PR unite (30g)
22

Preparare l'ambiente

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.

Altre issue di celo-org/docs

Tutte le issue di celo-org/docs

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.