Skip to content

Commit 0daf25c

Browse files
committed
default sign structured policy + list real access tokens
1 parent 35f0a41 commit 0daf25c

File tree

2 files changed

+80
-24
lines changed

2 files changed

+80
-24
lines changed

apps/dashboard/src/app/team/[team_slug]/[project_slug]/transactions/server-wallets/components/create-server-wallet.client.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,33 @@ export default function CreateServerWallet(props: {
250250
},
251251
],
252252
},
253+
{
254+
type: "eoa:signStructuredMessage",
255+
structuredPatterns: {
256+
userOpV06: {},
257+
userOpV07: {},
258+
},
259+
metadataPatterns: [
260+
{
261+
key: "projectId",
262+
rule: {
263+
pattern: props.project.id,
264+
},
265+
},
266+
{
267+
key: "teamId",
268+
rule: {
269+
pattern: props.project.teamId,
270+
},
271+
},
272+
{
273+
key: "type",
274+
rule: {
275+
pattern: "server-wallet",
276+
},
277+
},
278+
],
279+
},
253280
],
254281
metadata: {
255282
projectId: props.project.id,

apps/dashboard/src/app/team/[team_slug]/[project_slug]/transactions/server-wallets/components/list-access-tokens.client.tsx

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Loader2, Trash2 } from "lucide-react";
1717
import { useState } from "react";
1818
import { toast } from "sonner";
1919
import { THIRDWEB_VAULT_URL } from "../../../../../../../@/constants/env";
20+
import { listAccessTokens } from "@thirdweb-dev/vault-sdk/dist/types/sdk";
2021

2122
export default function ListAccessTokensButton(props: {
2223
projectId: string;
@@ -29,9 +30,7 @@ export default function ListAccessTokensButton(props: {
2930

3031
// TODO allow passing permissions to the access token
3132
const createAccessTokenMutation = useMutation({
32-
mutationFn: async (args: {
33-
adminKey: string;
34-
}) => {
33+
mutationFn: async (args: { adminKey: string }) => {
3534
const vaultClient = await createVaultClient({
3635
baseUrl: THIRDWEB_VAULT_URL,
3736
});
@@ -160,6 +159,33 @@ export default function ListAccessTokensButton(props: {
160159
},
161160
],
162161
},
162+
{
163+
type: "eoa:signStructuredMessage",
164+
structuredPatterns: {
165+
userOpV06: {},
166+
userOpV07: {},
167+
},
168+
metadataPatterns: [
169+
{
170+
key: "projectId",
171+
rule: {
172+
pattern: props.projectId,
173+
},
174+
},
175+
{
176+
key: "teamId",
177+
rule: {
178+
pattern: props.teamId,
179+
},
180+
},
181+
{
182+
key: "type",
183+
rule: {
184+
pattern: "server-wallet",
185+
},
186+
},
187+
],
188+
},
163189
],
164190
metadata: {
165191
projectId: props.projectId,
@@ -192,10 +218,7 @@ export default function ListAccessTokensButton(props: {
192218
});
193219

194220
const revokeAccessTokenMutation = useMutation({
195-
mutationFn: async (args: {
196-
adminKey: string;
197-
accessTokenId: string;
198-
}) => {
221+
mutationFn: async (args: { adminKey: string; accessTokenId: string }) => {
199222
setDeletingTokenId(args.accessTokenId);
200223
const vaultClient = await createVaultClient({
201224
baseUrl: THIRDWEB_VAULT_URL,
@@ -237,25 +260,31 @@ export default function ListAccessTokensButton(props: {
237260
const listAccessTokensQuery = useQuery({
238261
queryKey: ["list-access-tokens", maskSecret(adminKey)],
239262
queryFn: async () => {
240-
// TODO (engine-cloud): need the command in vault
241-
await new Promise((resolve) => setTimeout(resolve, 1000));
242-
// Return stub data for now
243-
return {
244-
accessTokens: [
245-
{
246-
key: "stub_1234567890abcdef",
247-
id: "token_1",
248-
},
249-
{
250-
key: "stub_1234567890abcdef",
251-
id: "token_2",
252-
},
253-
{
254-
key: "stub_1234567890abcdef",
255-
id: "token_3",
263+
const vaultClient = await createVaultClient({
264+
baseUrl: THIRDWEB_VAULT_URL,
265+
});
266+
const listResult = await listAccessTokens({
267+
client: vaultClient,
268+
request: {
269+
auth: {
270+
adminKey,
256271
},
257-
],
272+
options: {},
273+
},
274+
});
275+
276+
if (!listResult.success) {
277+
throw new Error(
278+
`Failed to list access tokens: ${listResult.error.message}`,
279+
);
280+
}
281+
return {
282+
accessTokens: listResult.data.items.map((t) => ({
283+
key: t.id, // todo: the actual user-facing key is not returned by this yet, fix this
284+
id: t.id,
285+
})),
258286
};
287+
// Return stub data for now
259288
},
260289
enabled: !!adminKey,
261290
});

0 commit comments

Comments
 (0)