Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/large-snails-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix linking wallets for ecosystems
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Suspense, useRef, useState } from "react";
import { defineChain } from "../../../../chains/utils.js";
import type { ThirdwebClient } from "../../../../client/client.js";
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
import { linkProfile } from "../../../../wallets/in-app/web/lib/auth/index.js";
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
import type { EcosystemWalletId } from "../../../../wallets/wallet-types.js";
Expand Down Expand Up @@ -43,6 +44,12 @@
);
const [error, setError] = useState<string | undefined>();
const [showAll, setShowAll] = useState<boolean>(false);
const ecosystem = isEcosystemWallet(wallet)
? {
id: wallet.id,
partnerId: wallet.getConfig()?.partnerId,
}
: undefined;

Check warning on line 52 in packages/thirdweb/src/react/web/wallets/in-app/WalletAuth.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/in-app/WalletAuth.tsx#L47-L52

Added lines #L47 - L52 were not covered by tests

const back = () => {
setStatus("selecting");
Expand All @@ -59,6 +66,7 @@
strategy: "wallet",
wallet: walletToLink,
chain: wallet.getChain() || defineChain(1),
ecosystem,

Check warning on line 69 in packages/thirdweb/src/react/web/wallets/in-app/WalletAuth.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/in-app/WalletAuth.tsx#L69

Added line #L69 was not covered by tests
}).catch((e) => {
setError(e.message);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@
closeOpenedWindow: (openedWindow: Window) => {
openedWindow.close();
},
ecosystem: ecosystemInfo,

Check warning on line 265 in packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx#L265

Added line #L265 was not covered by tests
};

const connectPromise = (() => {
Expand Down
30 changes: 12 additions & 18 deletions packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useCallback, useEffect, useRef, useState } from "react";
import type { Chain } from "../../../../chains/types.js";
import type { ThirdwebClient } from "../../../../client/client.js";
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
Expand All @@ -9,7 +9,6 @@
preAuthenticate,
} from "../../../../wallets/in-app/web/lib/auth/index.js";
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
import type { EcosystemWalletId } from "../../../../wallets/wallet-types.js";
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
import { fontSize } from "../../../core/design-system/index.js";
import { setLastAuthProvider } from "../../../core/utils/storage.js";
Expand Down Expand Up @@ -54,7 +53,12 @@
const [verifyStatus, setVerifyStatus] = useState<VerificationStatus>("idle");
const [error, setError] = useState<string | undefined>();
const [accountStatus, setAccountStatus] = useState<AccountStatus>("sending");
const isEcosystem = useMemo(() => isEcosystemWallet(wallet.id), [wallet.id]);
const ecosystem = isEcosystemWallet(wallet)
? {
id: wallet.id,
partnerId: wallet.getConfig()?.partnerId,
}
: undefined;

Check warning on line 61 in packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx#L56-L61

Added lines #L56 - L61 were not covered by tests

const [screen] = useState<ScreenToShow>("base");

Expand All @@ -66,27 +70,15 @@
try {
if ("email" in userInfo) {
await preAuthenticate({
ecosystem: isEcosystem
? {
id: wallet.id as EcosystemWalletId,
partnerId: (wallet as Wallet<EcosystemWalletId>).getConfig()
?.partnerId,
}
: undefined,
ecosystem,

Check warning on line 73 in packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx#L73

Added line #L73 was not covered by tests
email: userInfo.email,
strategy: "email",
client: props.client,
});
setAccountStatus("sent");
} else if ("phone" in userInfo) {
await preAuthenticate({
ecosystem: isEcosystem
? {
id: wallet.id as EcosystemWalletId,
partnerId: (wallet as Wallet<EcosystemWalletId>).getConfig()
?.partnerId,
}
: undefined,
ecosystem,

Check warning on line 81 in packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx#L81

Added line #L81 was not covered by tests
phoneNumber: userInfo.phone,
strategy: "phone",
client: props.client,
Expand All @@ -100,7 +92,7 @@
setVerifyStatus("idle");
setAccountStatus("error");
}
}, [props.client, userInfo, wallet, isEcosystem]);
}, [props.client, userInfo, ecosystem]);

Check warning on line 95 in packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx#L95

Added line #L95 was not covered by tests

async function connect(otp: string) {
if ("email" in userInfo) {
Expand Down Expand Up @@ -133,13 +125,15 @@
strategy: "email",
email: userInfo.email,
verificationCode: otp,
ecosystem,

Check warning on line 128 in packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx#L128

Added line #L128 was not covered by tests
});
} else if ("phone" in userInfo) {
await linkProfile({
client: props.client,
strategy: "phone",
phoneNumber: userInfo.phone,
verificationCode: otp,
ecosystem,

Check warning on line 136 in packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx#L136

Added line #L136 was not covered by tests
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@
const { wallet, done, client, chain } = props;
const [error, setError] = useState<string | undefined>();
const [status, setStatus] = useState<"loading" | "error">("loading");
const ecosystem = isEcosystemWallet(wallet)
? {
id: wallet.id,
partnerId: wallet.getConfig()?.partnerId,
}
: undefined;

Check warning on line 219 in packages/thirdweb/src/react/web/wallets/shared/PassKeyLogin.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/PassKeyLogin.tsx#L214-L219

Added lines #L214 - L219 were not covered by tests

async function signup() {
setStatus("loading");
Expand All @@ -220,6 +226,7 @@
client,
strategy: "passkey",
type: "sign-up",
ecosystem,

Check warning on line 229 in packages/thirdweb/src/react/web/wallets/shared/PassKeyLogin.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/PassKeyLogin.tsx#L229

Added line #L229 was not covered by tests
});
} else {
await wallet.connect({
Expand Down
21 changes: 9 additions & 12 deletions packages/thirdweb/src/react/web/wallets/shared/SocialLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
const ewLocale = props.locale;
const locale = ewLocale.socialLoginScreen;
const themeObj = useCustomTheme();
const ecosystem = isEcosystemWallet(props.wallet)
? {
id: props.wallet.id,
partnerId: props.wallet.getConfig()?.partnerId,
}
: undefined;

Check warning on line 47 in packages/thirdweb/src/react/web/wallets/shared/SocialLogin.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/SocialLogin.tsx#L42-L47

Added lines #L42 - L47 were not covered by tests

const [authError, setAuthError] = useState<string | undefined>(undefined);
const { done, wallet } = props;
Expand All @@ -62,12 +68,7 @@
return loginWithOauthRedirect({
authOption: props.socialAuth,
client: props.client,
ecosystem: isEcosystemWallet(wallet)
? {
id: wallet.id,
partnerId: wallet.getConfig()?.partnerId,
}
: undefined,
ecosystem,

Check warning on line 71 in packages/thirdweb/src/react/web/wallets/shared/SocialLogin.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/SocialLogin.tsx#L71

Added line #L71 was not covered by tests
redirectUrl: walletConfig?.auth?.redirectUrl,
mode: walletConfig?.auth?.mode,
});
Expand All @@ -78,12 +79,7 @@
authOption: props.socialAuth,
themeObj,
client: props.client,
ecosystem: isEcosystemWallet(wallet)
? {
id: wallet.id,
partnerId: wallet.getConfig()?.partnerId,
}
: undefined,
ecosystem,

Check warning on line 82 in packages/thirdweb/src/react/web/wallets/shared/SocialLogin.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/SocialLogin.tsx#L82

Added line #L82 was not covered by tests
});

if (!socialWindow) {
Expand All @@ -99,6 +95,7 @@
closeOpenedWindow: (openedWindow) => {
openedWindow.close();
},
ecosystem,

Check warning on line 98 in packages/thirdweb/src/react/web/wallets/shared/SocialLogin.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/wallets/shared/SocialLogin.tsx#L98

Added line #L98 was not covered by tests
}).catch((e) => {
setAuthError(e.message);
throw e;
Expand Down
Loading