Skip to content

Commit 5232c1c

Browse files
committed
Merge remote-tracking branch 'origin/main' into ph/usageV2Imports
2 parents f0d073f + f8ebbe5 commit 5232c1c

File tree

9 files changed

+94
-76
lines changed

9 files changed

+94
-76
lines changed

.changeset/fair-trains-reply.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/lucky-seahorses-wink.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/young-cherries-beg.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

apps/login/src/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function RootLayout({
2727
children: React.ReactNode;
2828
}>) {
2929
return (
30-
<html lang="en" className="h-full w-full">
30+
<html lang="en" className="h-full w-full bg-black text-white">
3131
<body
3232
className={`${sansFont.variable} ${monoFont.variable} h-full w-full font-sans antialiased`}
3333
>

apps/login/src/app/page.tsx

Lines changed: 77 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
"use client";
22

33
import { useSearchParams } from "next/navigation";
4-
import { createThirdwebClient, getContract, sendTransaction } from "thirdweb";
4+
import { createThirdwebClient, getContract } from "thirdweb";
55
import { baseSepolia } from "thirdweb/chains";
66
import { addSessionKey, isActiveSigner } from "thirdweb/extensions/erc4337";
7-
import { ConnectEmbed, useActiveAccount } from "thirdweb/react";
7+
import {
8+
ConnectEmbed,
9+
TransactionButton,
10+
useActiveAccount,
11+
} from "thirdweb/react";
812
import { isContractDeployed } from "thirdweb/utils";
913

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

19-
const onAccept = async () => {
20-
if (!account) {
21-
throw new Error("No account found");
22-
}
23-
const accountContract = getContract({
24-
address: account.address,
25-
// hard coded for now
26-
chain: baseSepolia,
27-
client,
28-
});
29-
let hasSesionKey = false;
30-
// check if already added
31-
const accountDeployed = await isContractDeployed(accountContract);
32-
if (accountDeployed) {
33-
hasSesionKey = await isActiveSigner({
34-
contract: accountContract,
35-
signer: sesionKeySignerAddress,
36-
});
37-
}
38-
// if not added, send tx to add the session key
39-
if (!hasSesionKey) {
40-
const transaction = addSessionKey({
41-
account,
42-
contract: accountContract,
43-
sessionKeyAddress: sesionKeySignerAddress,
44-
// hard coded for now
45-
permissions: { approvedTargets: "*" },
46-
});
47-
await sendTransaction({
48-
account,
49-
transaction,
50-
});
51-
}
52-
};
53-
5423
const searchParams = useSearchParams();
5524
const code = searchParams.get("code");
5625
const clientId = searchParams.get("clientId");
@@ -61,32 +30,82 @@ export default function Page() {
6130
return (
6231
<div className="grid h-full w-full place-items-center">
6332
{account ? (
64-
<div>
65-
<h1>Permissions Screen</h1>
33+
<div className="flex flex-col gap-4 rounded-lg border border-gray-800 p-12">
34+
<h1 className="font-bold text-3xl">Grant Permissions</h1>
35+
<p>
36+
<strong>App.xyz</strong> is asking you to grant it the following
37+
permissions:
38+
</p>
6639
<ul>
67-
<li>perm 1</li>
68-
<li>perm 2</li>
69-
<li>perm 3</li>
40+
<li>✅ Receive your identity information.</li>
41+
<li>
42+
✅ Interact with <strong>all</strong> contracts on{" "}
43+
<strong>Base Sepolia</strong>
44+
</li>
45+
<li>
46+
✅ Spend <strong>all</strong> your funds on{" "}
47+
<strong>Base Sepolia</strong>
48+
</li>
7049
</ul>
71-
<button
72-
type="button"
73-
onClick={() => {
74-
onAccept()
75-
.then(() => {
76-
// redirect back to the app
77-
window.location.href = `${redirect}${encodeHash(
78-
account.address,
79-
sesionKeySignerAddress,
80-
code || "",
81-
)}`;
82-
})
83-
.catch((e) => {
84-
console.error("failed", e);
50+
<p>
51+
By approving below you will grant <strong>App.xyz</strong> these
52+
permissions until <strong>02/02/2025</strong>.
53+
</p>
54+
<TransactionButton
55+
transaction={async () => {
56+
if (!account) {
57+
throw new Error("No account found");
58+
}
59+
const accountContract = getContract({
60+
address: account.address,
61+
// hard coded for now
62+
chain: baseSepolia,
63+
client,
64+
});
65+
let hasSesionKey = false;
66+
// check if already added
67+
const accountDeployed = await isContractDeployed(accountContract);
68+
if (accountDeployed) {
69+
hasSesionKey = await isActiveSigner({
70+
contract: accountContract,
71+
signer: sesionKeySignerAddress,
72+
});
73+
}
74+
// if not added, send tx to add the session key
75+
if (!hasSesionKey) {
76+
return addSessionKey({
77+
account,
78+
contract: accountContract,
79+
sessionKeyAddress: sesionKeySignerAddress,
80+
// hard coded for now
81+
permissions: { approvedTargets: "*" },
8582
});
83+
}
84+
throw "already-added";
85+
}}
86+
onError={(e) => {
87+
if (typeof e === "string" && e === "already-added") {
88+
// redirect back to the app
89+
window.location.href = `${redirect}${encodeHash(
90+
account.address,
91+
sesionKeySignerAddress,
92+
code || "",
93+
)}`;
94+
} else {
95+
console.error(e);
96+
}
97+
}}
98+
onTransactionConfirmed={() => {
99+
// redirect back to the app
100+
window.location.href = `${redirect}${encodeHash(
101+
account.address,
102+
sesionKeySignerAddress,
103+
code || "",
104+
)}`;
86105
}}
87106
>
88-
Accept
89-
</button>
107+
Approve
108+
</TransactionButton>
90109
</div>
91110
) : (
92111
<ConnectEmbed

packages/service-utils/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @thirdweb-dev/service-utils
22

3+
## 0.8.3
4+
5+
### Patch Changes
6+
7+
- [#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
8+
9+
- [#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
10+
311
## 0.8.2
412

513
### Patch Changes

packages/service-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@thirdweb-dev/service-utils",
3-
"version": "0.8.2",
3+
"version": "0.8.3",
44
"type": "module",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

packages/wagmi-adapter/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @thirdweb-dev/wagmi-adapter
22

3+
## 0.2.11
4+
5+
### Patch Changes
6+
7+
- [#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
8+
39
## 0.2.10
410

511
## 0.2.9

packages/wagmi-adapter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@thirdweb-dev/wagmi-adapter",
3-
"version": "0.2.10",
3+
"version": "0.2.11",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/thirdweb-dev/js.git#main"

0 commit comments

Comments
 (0)