Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ph/usageV2Imports
Browse files Browse the repository at this point in the history
  • Loading branch information
arcoraven committed Jan 31, 2025
2 parents f0d073f + f8ebbe5 commit 5232c1c
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 76 deletions.
5 changes: 0 additions & 5 deletions .changeset/fair-trains-reply.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/lucky-seahorses-wink.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/young-cherries-beg.md

This file was deleted.

2 changes: 1 addition & 1 deletion apps/login/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
return (
<html lang="en" className="h-full w-full">
<html lang="en" className="h-full w-full bg-black text-white">
<body
className={`${sansFont.variable} ${monoFont.variable} h-full w-full font-sans antialiased`}
>
Expand Down
135 changes: 77 additions & 58 deletions apps/login/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
"use client";

import { useSearchParams } from "next/navigation";
import { createThirdwebClient, getContract, sendTransaction } from "thirdweb";
import { createThirdwebClient, getContract } from "thirdweb";
import { baseSepolia } from "thirdweb/chains";
import { addSessionKey, isActiveSigner } from "thirdweb/extensions/erc4337";
import { ConnectEmbed, useActiveAccount } from "thirdweb/react";
import {
ConnectEmbed,
TransactionButton,
useActiveAccount,
} from "thirdweb/react";
import { isContractDeployed } from "thirdweb/utils";

const sesionKeySignerAddress = "0x6f700ba0258886411D2536399624EAa7158d1742";
Expand All @@ -16,41 +20,6 @@ const client = createThirdwebClient({
export default function Page() {
const account = useActiveAccount();

const onAccept = async () => {
if (!account) {
throw new Error("No account found");
}
const accountContract = getContract({
address: account.address,
// hard coded for now
chain: baseSepolia,
client,
});
let hasSesionKey = false;
// check if already added
const accountDeployed = await isContractDeployed(accountContract);
if (accountDeployed) {
hasSesionKey = await isActiveSigner({
contract: accountContract,
signer: sesionKeySignerAddress,
});
}
// if not added, send tx to add the session key
if (!hasSesionKey) {
const transaction = addSessionKey({
account,
contract: accountContract,
sessionKeyAddress: sesionKeySignerAddress,
// hard coded for now
permissions: { approvedTargets: "*" },
});
await sendTransaction({
account,
transaction,
});
}
};

const searchParams = useSearchParams();
const code = searchParams.get("code");
const clientId = searchParams.get("clientId");
Expand All @@ -61,32 +30,82 @@ export default function Page() {
return (
<div className="grid h-full w-full place-items-center">
{account ? (
<div>
<h1>Permissions Screen</h1>
<div className="flex flex-col gap-4 rounded-lg border border-gray-800 p-12">
<h1 className="font-bold text-3xl">Grant Permissions</h1>
<p>
<strong>App.xyz</strong> is asking you to grant it the following
permissions:
</p>
<ul>
<li>perm 1</li>
<li>perm 2</li>
<li>perm 3</li>
<li>✅ Receive your identity information.</li>
<li>
✅ Interact with <strong>all</strong> contracts on{" "}
<strong>Base Sepolia</strong>
</li>
<li>
✅ Spend <strong>all</strong> your funds on{" "}
<strong>Base Sepolia</strong>
</li>
</ul>
<button
type="button"
onClick={() => {
onAccept()
.then(() => {
// redirect back to the app
window.location.href = `${redirect}${encodeHash(
account.address,
sesionKeySignerAddress,
code || "",
)}`;
})
.catch((e) => {
console.error("failed", e);
<p>
By approving below you will grant <strong>App.xyz</strong> these
permissions until <strong>02/02/2025</strong>.
</p>
<TransactionButton
transaction={async () => {
if (!account) {
throw new Error("No account found");
}
const accountContract = getContract({
address: account.address,
// hard coded for now
chain: baseSepolia,
client,
});
let hasSesionKey = false;
// check if already added
const accountDeployed = await isContractDeployed(accountContract);
if (accountDeployed) {
hasSesionKey = await isActiveSigner({
contract: accountContract,
signer: sesionKeySignerAddress,
});
}
// if not added, send tx to add the session key
if (!hasSesionKey) {
return addSessionKey({
account,
contract: accountContract,
sessionKeyAddress: sesionKeySignerAddress,
// hard coded for now
permissions: { approvedTargets: "*" },
});
}
throw "already-added";
}}
onError={(e) => {
if (typeof e === "string" && e === "already-added") {
// redirect back to the app
window.location.href = `${redirect}${encodeHash(
account.address,
sesionKeySignerAddress,
code || "",
)}`;
} else {
console.error(e);
}
}}
onTransactionConfirmed={() => {
// redirect back to the app
window.location.href = `${redirect}${encodeHash(
account.address,
sesionKeySignerAddress,
code || "",
)}`;
}}
>
Accept
</button>
Approve
</TransactionButton>
</div>
) : (
<ConnectEmbed
Expand Down
8 changes: 8 additions & 0 deletions packages/service-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @thirdweb-dev/service-utils

## 0.8.3

### Patch Changes

- [#6121](https://github.com/thirdweb-dev/js/pull/6121) [`6ed2fd1`](https://github.com/thirdweb-dev/js/commit/6ed2fd13de1638bcf1c28fd4fdbeb00c0d449994) Thanks [@arcoraven](https://github.com/arcoraven)! - [service-utils] import LZ4 codec

- [#6120](https://github.com/thirdweb-dev/js/pull/6120) [`a22457a`](https://github.com/thirdweb-dev/js/commit/a22457a69cc6667ac13599d10ebddc41ceafa0ff) Thanks [@arcoraven](https://github.com/arcoraven)! - [service-utils] Expose kafkajs config

## 0.8.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/service-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/service-utils",
"version": "0.8.2",
"version": "0.8.3",
"type": "module",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/wagmi-adapter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @thirdweb-dev/wagmi-adapter

## 0.2.11

### Patch Changes

- [#6117](https://github.com/thirdweb-dev/js/pull/6117) [`ae675db`](https://github.com/thirdweb-dev/js/commit/ae675db8c86a9e4cddb6eb208cd132e0eeaa1978) Thanks [@gregfromstl](https://github.com/gregfromstl)! - Fixes getProvider autoconnections with account factory

## 0.2.10

## 0.2.9
Expand Down
2 changes: 1 addition & 1 deletion packages/wagmi-adapter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/wagmi-adapter",
"version": "0.2.10",
"version": "0.2.11",
"repository": {
"type": "git",
"url": "git+https://github.com/thirdweb-dev/js.git#main"
Expand Down

0 comments on commit 5232c1c

Please sign in to comment.