Skip to content

Commit

Permalink
Update playground SSV
Browse files Browse the repository at this point in the history
  • Loading branch information
yashovardhan committed Sep 19, 2024
1 parent d6642e8 commit a32671f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
10 changes: 3 additions & 7 deletions web-modal-sdk/react-modal-playground/src/services/evmProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getPublicCompressed } from "@toruslabs/eccrypto";
import type { IProvider } from "@web3auth/base";
import { ContractFactory, ethers } from "ethers";

Expand All @@ -8,12 +7,9 @@ import { IWalletProvider } from "./walletProvider";
const ethersWeb3Provider = (provider: IProvider | null, uiConsole: (...args: unknown[]) => void): IWalletProvider => {
const getPublicKey = async (): Promise<string> => {
try {
const privKey: string = await provider?.request({
method: "eth_private_key",
});
const pubkey = getPublicCompressed(Buffer.from(privKey, "hex")).toString("hex");

return pubkey;
const pubKey: string = await provider.request({ method: "public_key" });
// Remove 0x and return the compressed public key
return pubKey.slice(2) as string;
} catch (error: any) {
uiConsole(error);
return error.toString();
Expand Down
10 changes: 10 additions & 0 deletions web-modal-sdk/react-modal-playground/src/services/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,16 @@ export const Playground = ({ children }: IPlaygroundProps) => {
"Parsed Id Token: ",
await parseToken(idTokenInFrontend)
);
} else {
uiConsole(
"Validation Failed!",
"Public Key from Provider: ",
pubkey,
"Public Key from decoded JWT: ",
pubKeyFromIdToken,
"Parsed Id Token: ",
await parseToken(idTokenInFrontend)
);
}
} else {
const jwks = jose.createRemoteJWKSet(new URL("https://authjs.web3auth.io/jwks"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AuthAdapter } from "@web3auth/auth-adapter";
import { AuthAdapter, MFA_LEVELS } from "@web3auth/auth-adapter";
import { UX_MODE, WEB3AUTH_NETWORK } from "@web3auth/base";
import { getDefaultExternalAdapters } from "@web3auth/default-evm-adapter";
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
import { Web3AuthOptions } from "@web3auth/modal";
import { WalletServicesPlugin } from "@web3auth/wallet-services-plugin";
import { BUTTON_POSITION, CONFIRMATION_STRATEGY, WalletServicesPlugin } from "@web3auth/wallet-services-plugin";

import { chain } from "../config/chainConfig";

Expand All @@ -24,7 +24,7 @@ const web3AuthOptions: Web3AuthOptions = {

const authAdapter = new AuthAdapter({
loginSettings: {
mfaLevel: "optional",
mfaLevel: MFA_LEVELS.OPTIONAL,
},
adapterSettings: {
uxMode: UX_MODE.REDIRECT, // "redirect" | "popup"
Expand All @@ -33,7 +33,10 @@ const authAdapter = new AuthAdapter({

const walletServicesPlugin = new WalletServicesPlugin({
wsEmbedOpts: {},
walletInitOptions: { whiteLabel: { showWidgetButton: true, buttonPosition: "bottom-right" } },
walletInitOptions: {
whiteLabel: { showWidgetButton: true, buttonPosition: BUTTON_POSITION.BOTTOM_RIGHT },
confirmationStrategy: CONFIRMATION_STRATEGY.MODAL,
},
});

const adapters = await getDefaultExternalAdapters({ options: web3AuthOptions });
Expand Down

0 comments on commit a32671f

Please sign in to comment.