Skip to content

Commit bb5ae25

Browse files
authored
fix: Handling cases where social login is reconnected (#26)
1 parent 6277f6f commit bb5ae25

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/sdk/src/providers/gno-wallet/gno-social-wallet.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,27 @@ export class GnoSocialWalletProvider extends GnoWalletProvider {
120120
...(this.extraLoginOptions && { extraLoginOptions: this.extraLoginOptions }),
121121
};
122122

123+
if (this.web3auth.connected) {
124+
const userInfo = await this.web3auth.getUserInfo();
125+
const currentLoginType = userInfo.typeOfLogin;
126+
127+
if (currentLoginType !== this.socialType) {
128+
const networks = [...this.networks];
129+
await this.disconnect();
130+
131+
this.setNetworks(networks);
132+
this.web3auth = await this.initializeWeb3Auth();
133+
} else {
134+
const privateKey = await this.requestPrivateKey();
135+
const privateKeyBytes = hexToUint8Array(privateKey);
136+
const wallet = await GnoWallet.fromPrivateKey(privateKeyBytes, {
137+
addressPrefix: this.currentNetwork.addressPrefix,
138+
});
139+
this.wallet = wallet;
140+
return this.connectProvider();
141+
}
142+
}
143+
123144
const provider = await this.web3auth.connectTo(WALLET_ADAPTERS.AUTH, connectOptions);
124145

125146
if (!provider) {

0 commit comments

Comments
 (0)