From 31d62d75d5b0c4f799ba977b977b81b1fddda747 Mon Sep 17 00:00:00 2001 From: Manuel Turetta Date: Wed, 28 Jun 2023 15:25:21 -0500 Subject: [PATCH] docs: update documentation for @desmoslabs/desmjs-web3auth-web --- docs/docs/packages/web3auth-web.md | 48 +++++++++++++++++++----------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/docs/docs/packages/web3auth-web.md b/docs/docs/packages/web3auth-web.md index 4562d3c38..30b33a418 100644 --- a/docs/docs/packages/web3auth-web.md +++ b/docs/docs/packages/web3auth-web.md @@ -36,7 +36,7 @@ get one in the [Web3Auth docs](https://web3auth.io/docs/developer-dashboard/get- To support the login with different methods, we use the `OpenLoginAdapter` plugin: ```ts -import {OpenloginAdapter} from "@web3auth/openlogin-adapter"; +import { OpenloginAdapter } from "@web3auth/openlogin-adapter"; const openloginAdapter = new OpenloginAdapter({ adapterSettings: { @@ -49,6 +49,9 @@ const openloginAdapter = new OpenloginAdapter({ } } }); + +// Confifure the openlogin adapter on the web3auth instance. +web3auth.configureAdapter(openloginAdapter); ``` ### Building a `DesmosClient` instance using `Web3AuthSigner` @@ -58,24 +61,35 @@ with the private key obtained from `Web3Auth`. Once you have the `Signer` instan a `DesmosClient` instance. ```ts -import {SigningMode} from "@desmoslabs/desmjs"; -import {web3AuthSigner} from "@desmoslabs/desmjs-web3auth-web"; - -const signer = web3AuthSigner(SigningMode.DIRECT, { - authMode: "DAPP", - clientId: "YOUR WEB3AUTH CLIENT ID", - chainConfig: { - chainNamespace: "other", - blockExplorer: "https://bigdipper.live/desmos", - displayName: "Desmos", - chainId: "desmos-mainnet", - ticker: "DSM", - tickerName: "Desmos" +import { PrivateKeySigner, SigningMode } from "@desmoslabs/desmjs"; +import { Web3AuthPrivateKeyProvider } from "@desmoslabs/desmjs-web3auth-web"; + +// Instantiate the Web3AuthPrivateKeyProvider. +const privateKeyProvider = new Web3AuthPrivateKeyProvider( + web3Auth, + { + modalConfig: { + authMode: "DAPP", + clientId: "YOUR WEB3AUTH CLIENT ID", + chainConfig: { + chainNamespace: "other", + blockExplorer: "https://bigdipper.live/desmos", + displayName: "Desmos", + chainId: "desmos-mainnet", + ticker: "DSM", + tickerName: "Desmos", + }, + }, } -}, { - adapters: [openloginAdapter], -}); +); + +// Instantiate the signer that uses the Web3AuthPrivateKeyProvider. +const signer = new PrivateKeySigner( + privateKeyProvider, + SigningMode.DIRECT +); +// Connect to the signer. await signer.connect(); const client = await DesmosClient.connectWithSigner('https://rpc.mainnet.desmos.network', signer, {