Skip to content

Commit

Permalink
Merge branch 'main' into yash/update-implementations-2
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaryash90 authored Mar 3, 2025
2 parents 1f4c179 + 9fcf1b8 commit 971bbc5
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 57 deletions.
1 change: 0 additions & 1 deletion apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ export type RotateSecretKeyAPIReturnType = {
data: {
secret: string;
secretMasked: string;
secretHash: string;
};
};

Expand Down
36 changes: 33 additions & 3 deletions apps/dashboard/src/app/login/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const LazyOnboardingUI = lazy(
() => import("./onboarding/on-boarding-ui.client"),
);

const wallets = [
const loginOptions = [
inAppWallet({
auth: {
options: [
Expand All @@ -45,9 +45,27 @@ const wallets = [
createWallet("io.zerion.wallet"),
];

const inAppWalletLoginOptions = [
inAppWallet({
auth: {
options: [
"google",
"apple",
"facebook",
"github",
"email",
"phone",
"passkey",
"wallet",
],
},
}),
];

export function LoginAndOnboardingPage(props: {
account: Account | undefined;
redirectPath: string;
loginWithInAppWallet: boolean;
}) {
return (
<div className="relative flex min-h-dvh flex-col overflow-hidden bg-background">
Expand Down Expand Up @@ -91,6 +109,7 @@ export function LoginAndOnboardingPage(props: {
<LoginAndOnboardingPageContent
account={props.account}
redirectPath={props.redirectPath}
loginWithInAppWallet={props.loginWithInAppWallet}
/>
</div>
);
Expand All @@ -99,6 +118,7 @@ export function LoginAndOnboardingPage(props: {
export function LoginAndOnboardingPageContent(props: {
account: Account | undefined;
redirectPath: string;
loginWithInAppWallet: boolean;
}) {
return (
<div className="relative flex grow flex-col">
Expand All @@ -114,6 +134,7 @@ export function LoginAndOnboardingPageContent(props: {
<PageContent
redirectPath={props.redirectPath}
account={props.account}
loginWithInAppWallet={props.loginWithInAppWallet}
/>
</ClientOnly>
</main>
Expand All @@ -139,6 +160,7 @@ function LoadingCard() {
function PageContent(props: {
redirectPath: string;
account: Account | undefined;
loginWithInAppWallet: boolean;
}) {
const [screen, setScreen] = useState<
| { id: "login" }
Expand Down Expand Up @@ -190,7 +212,12 @@ function PageContent(props: {
}

if (connectionStatus !== "connected" || screen.id === "login") {
return <CustomConnectEmbed onLogin={onLogin} />;
return (
<CustomConnectEmbed
onLogin={onLogin}
loginWithInAppWallet={props.loginWithInAppWallet}
/>
);
}

if (screen.id === "onboarding") {
Expand All @@ -215,6 +242,7 @@ function PageContent(props: {

function CustomConnectEmbed(props: {
onLogin: () => void;
loginWithInAppWallet: boolean;
}) {
const { theme } = useTheme();
const client = useThirdwebClient();
Expand Down Expand Up @@ -257,7 +285,9 @@ function CustomConnectEmbed(props: {
return isLoggedInResult;
},
}}
wallets={wallets}
wallets={
props.loginWithInAppWallet ? inAppWalletLoginOptions : loginOptions
}
client={client}
modalSize="wide"
theme={getSDKTheme(theme === "light" ? "light" : "dark")}
Expand Down
13 changes: 10 additions & 3 deletions apps/dashboard/src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { isValidEncodedRedirectPath } from "./isValidEncodedRedirectPath";

export default async function Page(props: {
searchParams: Promise<{
next?: string;
next: string | string[] | undefined;
"in-app-wallet": string | string[] | undefined;
}>;
}) {
const nextPath = (await props.searchParams).next;
const searchParams = await props.searchParams;
const nextPath =
typeof searchParams.next === "string" ? searchParams.next : undefined;
const account = await getRawAccount();

// don't redirect away from login page if authToken is already present and onboarding is done
Expand All @@ -20,6 +23,10 @@ export default async function Page(props: {
nextPath && isValidEncodedRedirectPath(nextPath) ? nextPath : "/team";

return (
<LoginAndOnboardingPage account={account} redirectPath={redirectPath} />
<LoginAndOnboardingPage
account={account}
redirectPath={redirectPath}
loginWithInAppWallet={searchParams["in-app-wallet"] === "true"}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function NebulaLoginPage(props: {

{showPage === "connect" && (
<LoginAndOnboardingPageContent
loginWithInAppWallet={false}
account={props.account}
redirectPath={
message ? `/?prompt=${encodeURIComponent(message)}` : "/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ function Story(props: {
await new Promise((resolve) => setTimeout(resolve, 1000));
return {
data: {
secret: new Array(86).fill("x").join(""),
secretHash: new Array(64).fill("x").join(""),
secretMasked: "123...4567",
secret: `sk_${new Array(86).fill("x").join("")}`,
secretMasked: "sk_123...4567",
},
};
}}
Expand Down
93 changes: 48 additions & 45 deletions packages/thirdweb/src/utils/bytecode/resolveImplementation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,54 +20,57 @@ import { getContract } from "../../contract/contract.js";
import { deployContract } from "../../contract/deployment/deploy-with-abi.js";
import { resolveImplementation } from "./resolveImplementation.js";

describe("Resolve implementation", async () => {
it("should extract implementation address for minimal proxy contract", async () => {
const resolved = resolveImplementation(NFT_DROP_CONTRACT);
expect((await resolved).address).to.equal(NFT_DROP_IMPLEMENTATION);
});

it("should extract implementation address for matic proxy contract", async () => {
const resolved = resolveImplementation(POLYGON_USDT_PROXY_CONTRACT);
expect((await resolved).address).to.equal(
POLYGON_USDT_IMPLEMENTATION.toLowerCase(),
);
});

it("should extract implementation address for base USDC proxy contract", async () => {
const resolved = resolveImplementation(BASE_USDC_PROXY_CONTRACT);
expect((await resolved).address).to.equal(
BASE_USDC_IMPLEMENTATION.toLowerCase(),
);
});

it("should extract implementation address for ERC1967 proxy contract", async () => {
const implementationAddress = await deployContract({
client: TEST_CLIENT,
chain: ANVIL_CHAIN,
account: TEST_ACCOUNT_A,
bytecode: DUMMY_BYTECODE,
abi: [],
describe.runIf(process.env.TW_SECRET_KEY)(
"Resolve implementation",
async () => {
it("should extract implementation address for minimal proxy contract", async () => {
const resolved = resolveImplementation(NFT_DROP_CONTRACT);
expect((await resolved).address).to.equal(NFT_DROP_IMPLEMENTATION);
});

const proxyAddress = await deployContract({
client: TEST_CLIENT,
chain: ANVIL_CHAIN,
account: TEST_ACCOUNT_A,
bytecode: ERC1967_PROXY_BYTECODE,
abi: ERC1967_PROXY_CONSTRUCTOR_ABI as Abi,
constructorParams: {
logic: implementationAddress,
data: "0x",
},
it("should extract implementation address for matic proxy contract", async () => {
const resolved = resolveImplementation(POLYGON_USDT_PROXY_CONTRACT);
expect((await resolved).address).to.equal(
POLYGON_USDT_IMPLEMENTATION.toLowerCase(),
);
});

const proxy = getContract({
chain: ANVIL_CHAIN,
address: proxyAddress,
client: TEST_CLIENT,
it("should extract implementation address for base USDC proxy contract", async () => {
const resolved = resolveImplementation(BASE_USDC_PROXY_CONTRACT);
expect((await resolved).address).to.equal(
BASE_USDC_IMPLEMENTATION.toLowerCase(),
);
});

const resolved = await resolveImplementation(proxy);
expect(resolved.address).to.equal(implementationAddress);
});
});
it("should extract implementation address for ERC1967 proxy contract", async () => {
const implementationAddress = await deployContract({
client: TEST_CLIENT,
chain: ANVIL_CHAIN,
account: TEST_ACCOUNT_A,
bytecode: DUMMY_BYTECODE,
abi: [],
});

const proxyAddress = await deployContract({
client: TEST_CLIENT,
chain: ANVIL_CHAIN,
account: TEST_ACCOUNT_A,
bytecode: ERC1967_PROXY_BYTECODE,
abi: ERC1967_PROXY_CONSTRUCTOR_ABI as Abi,
constructorParams: {
logic: implementationAddress,
data: "0x",
},
});

const proxy = getContract({
chain: ANVIL_CHAIN,
address: proxyAddress,
client: TEST_CLIENT,
});

const resolved = await resolveImplementation(proxy);
expect(resolved.address).to.equal(implementationAddress);
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const contract = getContract({
address: "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8",
});

describe.sequential(
describe.runIf(process.env.TW_SECRET_KEY).sequential(
"SmartWallet 0.7 core tests",
{
timeout: 240_000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const client = TEST_CLIENT;
const DEFAULT_FACTORY_ADDRESS = "0xB1846E893CA01c5Dcdaa40371C1e13f2e0Df5717";
const DEFAULT_VALIDATOR_ADDRESS = "0x7D3631d823e0De311DC86f580946EeF2eEC81fba";

describe.sequential(
describe.runIf(process.env.TW_SECRET_KEY).sequential(
"SmartWallet modular tests",
{
retry: 0,
Expand Down

0 comments on commit 971bbc5

Please sign in to comment.