Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Return Social User information #21

Merged
merged 5 commits into from
Jan 22, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/sdk/src/providers/gno-wallet/gno-social-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GnoWallet } from '@gnolang/gno-js-client';
import { CustomChainConfig, WALLET_ADAPTERS } from '@web3auth/base';
import { CustomChainConfig, UserInfo, WALLET_ADAPTERS } from '@web3auth/base';
import { CommonPrivateKeyProvider } from '@web3auth/base-provider';
import { Web3AuthNoModal } from '@web3auth/no-modal';
import { OpenloginAdapter } from '@web3auth/openlogin-adapter';
Expand Down Expand Up @@ -124,6 +124,7 @@ export class GnoSocialWalletProvider extends GnoWalletProvider {
const openloginAdapter = new OpenloginAdapter({
privateKeyProvider: privateKeyProvider,
adapterSettings: {
storageKey: 'session',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to get the settings from the user.

clientId: config.clientId,
uxMode: 'popup',
loginConfig: {
Expand Down Expand Up @@ -172,6 +173,7 @@ export class GnoSocialWalletProvider extends GnoWalletProvider {
const openloginAdapter = new OpenloginAdapter({
privateKeyProvider: privateKeyProvider,
adapterSettings: {
storageKey: 'session',
uxMode: 'popup',
loginConfig: {
[socialType]: {
Expand Down Expand Up @@ -224,6 +226,7 @@ export class GnoSocialWalletProvider extends GnoWalletProvider {
const openloginAdapter = new OpenloginAdapter({
privateKeyProvider: privateKeyProvider,
adapterSettings: {
storageKey: 'session',
uxMode: 'popup',
loginConfig: {
[socialType]: {
Expand All @@ -243,4 +246,12 @@ export class GnoSocialWalletProvider extends GnoWalletProvider {
web3auth.configureAdapter(openloginAdapter);
return new GnoSocialWalletProvider(web3auth, socialType, [networkConfig]);
}

public async getSocialUserProfile(): Promise<Partial<UserInfo>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more things

  1. override the UserInfo type.

  2. add a function to the TM2Wallet interface.

  3. make it possible to call the same function from adena-sdk.

  • We need some guard logic to check if it is an instance of GnoSocialWallet.

if (!this.web3auth) {
throw new Error('Not initialized web3 provider.');
}

return await this.web3auth.getUserInfo();
}
}
Loading