Continuing the discussion from Keeping Multiple Adaptors Connected?:
What I want to achieve: After login, I also want to connect a guardian using social auth so it can sign transactions.
Continuing the discussion from Keeping Multiple Adaptors Connected?:
What I want to achieve: After login, I also want to connect a guardian using social auth so it can sign transactions.
useEffect(() => {
async function init() {
try {
setIsLoading(true);
const web3AuthInstance = new Web3Auth({
clientId: web3AuthKey,
chainConfig,
web3AuthNetwork:
chainConfig.displayName === "Base Mainnet"
? OPENLOGIN_NETWORK.SAPPHIRE_MAINNET
: OPENLOGIN_NETWORK.SAPPHIRE_DEVNET,
uiConfig: {
appName: "Wildfire",
mode: systemTheme,
},
});
const openloginAdapter = new OpenloginAdapter({
loginSettings: {
mfaLevel: "optional",
},
adapterSettings: {
uxMode: "redirect", // "redirect" | "popup",
mfaSettings: {
deviceShareFactor: {
enable: false,
priority: 1,
mandatory: false,
},
backUpShareFactor: {
enable: true,
priority: 3,
mandatory: false,
},
socialBackupFactor: {
enable: true,
priority: 2,
mandatory: true,
},
passwordFactor: {
enable: true,
priority: 4,
mandatory: false,
},
},
},
});
const coinbaseAdapter = new CoinbaseAdapter({
clientId: web3AuthKey,
sessionTime: 3600, // 1 hour in seconds
chainConfig,
web3AuthNetwork:
chainConfig.displayName === "Base Mainnet"
? OPENLOGIN_NETWORK.SAPPHIRE_MAINNET
: OPENLOGIN_NETWORK.SAPPHIRE_DEVNET,
});
web3AuthInstance.configureAdapter(openloginAdapter);
web3AuthInstance.configureAdapter(coinbaseAdapter);
await web3AuthInstance.initModal({
modalConfig: {
[WALLET_ADAPTERS.OPENLOGIN]: {
label: "openlogin",
loginMethods: {
wechat: {
showOnModal: false,
},
weibo: {
showOnModal: false,
},
twitch: {
showOnModal: false,
},
line: {
showOnModal: false,
},
kakao: {
showOnModal: false,
},
apple: {
showOnModal: false,
},
github: {
showOnModal: false,
},
linkedin: {
showOnModal: false,
},
email_passwordless: {
showOnModal: true,
},
sms_passwordless: {
showOnModal: true,
},
},
},
[WALLET_ADAPTERS.TORUS_EVM]: {
showOnModal: true,
},
},
});
if (web3AuthInstance.status === "connected") {
setWalletProvider(web3AuthInstance.provider);
setUser(await web3AuthInstance.getUserInfo());
setConnected(true);
}
setWeb3Auth(web3AuthInstance);
} catch (error) {
uiConsole(error);
} finally {
setIsLoading(false);
}
}
init();
}, [setWalletProvider, systemTheme]);
const setGuardian = async () => {
try {
{
const web3AuthInstanceGuardian = new Web3Auth({
clientId: web3AuthKeyGuardian,
chainConfig,
web3AuthNetwork:
chainConfig.displayName === "Base Mainnet"
? OPENLOGIN_NETWORK.SAPPHIRE_MAINNET
: OPENLOGIN_NETWORK.SAPPHIRE_DEVNET,
uiConfig: {
appName: "Guardian",
mode: systemTheme,
},
storageKey: "session",
});
const openloginAdapterGuardian = new OpenloginAdapter({
loginSettings: {
mfaLevel: "none",
},
adapterSettings: {
uxMode: "redirect", // "redirect" | "popup",
},
});
web3AuthInstanceGuardian.configureAdapter(openloginAdapterGuardian);
await web3AuthInstanceGuardian.initModal({
modalConfig: {
[WALLET_ADAPTERS.OPENLOGIN]: {
label: "openlogin",
loginMethods: {
google: {
showOnModal: false,
},
twitter: {
showOnModal: false,
},
discord: {
showOnModal: false,
},
facebook: {
showOnModal: false,
},
reddit: {
showOnModal: false,
},
wechat: {
showOnModal: false,
},
weibo: {
showOnModal: false,
},
twitch: {
showOnModal: false,
},
line: {
showOnModal: false,
},
kakao: {
showOnModal: false,
},
apple: {
showOnModal: false,
},
github: {
showOnModal: false,
},
linkedin: {
showOnModal: false,
},
email_passwordless: {
showOnModal: false,
},
sms_passwordless: {
showOnModal: true,
},
wallet_logins: {
showOnModal: false,
},
},
},
[WALLET_ADAPTERS.TORUS_EVM]: {
showOnModal: false,
},
[WALLET_ADAPTERS.COINBASE]: {
showOnModal: false,
},
[WALLET_ADAPTERS.METAMASK]: {
showOnModal: false,
},
[WALLET_ADAPTERS.PHANTOM]: {
showOnModal: false,
},
[WALLET_ADAPTERS.SOLFLARE]: {
showOnModal: false,
},
[WALLET_ADAPTERS.WALLET_CONNECT_V2]: {
showOnModal: false,
},
},
});
await web3AuthInstanceGuardian.connect();
}
} catch (error) {
console.log("Error connecting guardian ", error);
return "error";
}
};
Hey @shahvidhan017
You can sign transactions with the existing Web3Auth instance, can you please elaborate why this might be necessary for your use case, so that I get a clear picture how you’d want this to work?
Active login: Wallet A (web3 auth instance 1)
Secondary login: Wallet B (web3 auth instance 2)
What I want to to achieve:
Get private key of wallet A, encrypt it using private key of wallet B and store it.
So wallet B can be used to recover wallet A in case access to wallet A is lost.
Trying to create a recovery mechanism because the existing recovery mechanism from zerodev doesn’t seem to work. And I couldn’t find any in web3Auth docs as well.
Hey @shahvidhan017,
please let me try this on my side and will also check the feasibility of this solution, will it work the way you’re expecting it to.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.