Skip to content

Commit 0f0f141

Browse files
ci: add smoke test (#32)
1 parent e81844a commit 0f0f141

File tree

3 files changed

+118
-130
lines changed

3 files changed

+118
-130
lines changed

Diff for: .github/workflows/ci.yml

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Geist Dapp Kit
22

33
on:
4+
pull_request:
5+
branches:
6+
- 'draft'
7+
- 'main'
48
push:
59
branches:
610
- 'draft'
@@ -54,6 +58,7 @@ jobs:
5458

5559
deploy-storybook:
5660
needs: [build-storybook]
61+
if: github.ref == 'refs/heads/main'
5762
runs-on: ubuntu-latest
5863
steps:
5964
- uses: actions/checkout@v3
+112-126
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,125 @@
1-
import { Badge } from "@/components/ui/badge"
21
import {
3-
Card,
4-
CardContent,
5-
CardDescription,
6-
CardFooter,
7-
CardHeader,
8-
CardTitle,
9-
} from "@/components/ui/card"
10-
import { useGetAttestations } from "@/lib/eas/get-attestations"
11-
import { Address, Hex } from "viem"
12-
import { useChainId } from "wagmi"
13-
import { asAttestationMeta, AttestationMeta } from "./attestations"
14-
import { useMemo } from "react"
15-
import { Skeleton } from "@/components/ui/skeleton"
16-
import { Label } from "@radix-ui/react-label"
17-
import { Separator } from "@/components/ui/separator"
18-
import { getShortHex } from "@/utils/hex"
19-
import { format } from "date-fns"
20-
import { mainnet } from "viem/chains"
21-
import { SchemaBadge } from "./SchemaBadge"
2+
Card,
3+
CardContent,
4+
CardDescription,
5+
CardFooter,
6+
CardHeader,
7+
CardTitle,
8+
} from "@/components/ui/card";
9+
import { Separator } from "@/components/ui/separator";
10+
import { Skeleton } from "@/components/ui/skeleton";
11+
import { useGetAttestations } from "@/lib/eas/get-attestations";
12+
import { getShortHex } from "@/utils/hex";
13+
import { Label } from "@radix-ui/react-label";
14+
import { format } from "date-fns";
15+
import { useMemo } from "react";
16+
import { Address, Hex } from "viem";
17+
import { mainnet } from "viem/chains";
18+
import { useChainId } from "wagmi";
19+
import { SchemaBadge } from "./SchemaBadge";
20+
import { AttestationMeta, asAttestationMeta } from "./attestations";
2221

23-
// TODO indicate network
24-
const AttestationCardContent = ({ attestation }: { attestation: AttestationMeta }) => {
25-
const { from, to, schemaId, schemaName, schemaIndex } = attestation;
26-
if (!attestation) {
27-
return <Skeleton className="w-[100px] h-[20px] rounded-full" />
28-
}
29-
return (
30-
<CardContent>
31-
<div className="flex w-full items-center gap-2">
32-
<div className="grid flex-1 auto-rows-min gap-0.5">
33-
<div className="text-xs text-muted-foreground">Schema ID</div>
34-
<div className="flex items-center gap-1 text-2xl font-bold tabular-nums leading-none">
35-
<SchemaBadge chainId={mainnet.id} schemaId={schemaId} schemaIndex={schemaIndex} />
36-
<div className="flex flex-col">
37-
<div className="text-sm font-normal text-muted-foreground">
38-
<span className="text-sm font-normal">
39-
{schemaName}
40-
</span>
41-
</div>
42-
<span className="text-sm font-normal text-muted-foreground">
43-
{getShortHex(schemaId as Hex)}
44-
</span>
45-
</div>
46-
</div>
47-
</div>
48-
<Separator orientation="vertical" className="mx-2 h-10 w-px" />
49-
<div className="grid flex-1 auto-rows-min gap-0.5">
50-
<div className="text-xs text-muted-foreground">From</div>
51-
<div className="flex items-baseline gap-1 text-2xl font-bold tabular-nums leading-none">
52-
<span className="text-sm font-normal">
53-
{from}
54-
</span>
55-
</div>
56-
<div className="text-xs text-muted-foreground">To</div>
57-
<div className="flex items-baseline gap-1 text-2xl font-bold tabular-nums leading-none">
58-
<span className="text-sm font-normal">
59-
{to}
60-
</span>
61-
</div>
62-
</div>
63-
</div>
22+
// TODO indicate network
23+
const AttestationCardContent = ({
24+
attestation,
25+
}: { attestation: AttestationMeta }) => {
26+
const { from, to, schemaId, schemaName, schemaIndex } = attestation;
27+
if (!attestation) {
28+
return <Skeleton className="w-[100px] h-[20px] rounded-full" />;
29+
}
30+
return (
31+
<CardContent>
32+
<div className="flex w-full items-center gap-2">
33+
<div className="grid flex-1 auto-rows-min gap-0.5">
34+
<div className="text-xs text-muted-foreground">Schema ID</div>
35+
<div className="flex items-center gap-1 text-2xl font-bold tabular-nums leading-none">
36+
<SchemaBadge
37+
chainId={mainnet.id}
38+
schemaId={schemaId}
39+
schemaIndex={schemaIndex}
40+
/>
41+
<div className="flex flex-col">
42+
<div className="text-sm font-normal text-muted-foreground">
43+
<span className="text-sm font-normal">{schemaName}</span>
44+
</div>
45+
<span className="text-sm font-normal text-muted-foreground">
46+
{getShortHex(schemaId as Hex)}
47+
</span>
48+
</div>
49+
</div>
50+
</div>
51+
<Separator orientation="vertical" className="mx-2 h-10 w-px" />
52+
<div className="grid flex-1 auto-rows-min gap-0.5">
53+
<div className="text-xs text-muted-foreground">From</div>
54+
<div className="flex items-baseline gap-1 text-2xl font-bold tabular-nums leading-none">
55+
<span className="text-sm font-normal">{from}</span>
56+
</div>
57+
<div className="text-xs text-muted-foreground">To</div>
58+
<div className="flex items-baseline gap-1 text-2xl font-bold tabular-nums leading-none">
59+
<span className="text-sm font-normal">{to}</span>
60+
</div>
61+
</div>
62+
</div>
6463

65-
<Label></Label>
66-
</CardContent>
67-
)
68-
}
64+
<Label></Label>
65+
</CardContent>
66+
);
67+
};
6968

7069
// some key fields from https://easscan.org/offchain/attestation/view/0x49dff46654fe740241026c1a717ace9ec439abe26124cd925b0ba1df296433c5
7170
export const AttestationCard = ({
72-
attesterAddress
71+
attesterAddress,
7372
}: {
74-
attesterAddress: Address
73+
attesterAddress: Address;
7574
}) => {
75+
const chainId = useChainId();
76+
const { data, isSuccess } = useGetAttestations({
77+
chainId,
78+
address: attesterAddress,
79+
});
7680

77-
const chainId = useChainId();
78-
const { data, isSuccess } = useGetAttestations({
79-
chainId,
80-
address: attesterAddress
81-
});
81+
const attestation = useMemo(() => {
82+
if (!data) {
83+
return null;
84+
}
85+
return asAttestationMeta(data?.data?.attestations?.[0]);
86+
}, [isSuccess]);
87+
// 1. onchain vs offchain
8288

89+
// 2. grid
8390

84-
const attestation = useMemo(() => {
85-
if (!data) {
86-
return null;
87-
}
88-
return asAttestationMeta(data?.data?.attestations?.[0]);
89-
}, [isSuccess]);
90-
// 1. onchain vs offchain
91+
return (
92+
<Card>
93+
{attestation ? (
94+
<CardHeader>
95+
<CardTitle>Attestation</CardTitle>
96+
<CardDescription>
97+
<div className="flex flex-col">
98+
<div className="flex items-baseline ">
99+
<span className="text-xs font-normal">UID:</span>
100+
</div>
91101

92-
// 2. grid
102+
<div className="text-xs text-muted-foreground">
103+
{attestation.id}
104+
</div>
105+
</div>
93106

94-
return (
95-
96-
<Card>
97-
{
98-
attestation ? (
99-
<CardHeader>
100-
<CardTitle>Attestation</CardTitle>
101-
<CardDescription>
102-
<div className="flex flex-col">
103-
104-
<div className="flex items-baseline ">
105-
<span className="text-xs font-normal">
106-
UID:
107-
</span>
108-
</div>
109-
110-
<div className="text-xs text-muted-foreground">{attestation.id}</div>
111-
112-
</div>
113-
114-
<div className="flex flex-col">
115-
<span className="text-xs font-normal">
116-
TIMESTAMPS:
117-
</span>
118-
</div>
119-
<div className="text-xs text-muted-foreground">
120-
Created: {format(new Date(attestation.time * 1000), 'yyyy/MM/dd HH:MM:ss')}
121-
</div>
122-
123-
</CardDescription>
124-
</CardHeader>
125-
) : <Skeleton className="w-[100px] h-[20px] rounded-full" />
126-
}
127-
<CardContent>
128-
{
129-
attestation && (
130-
<AttestationCardContent attestation={attestation} />
131-
)
132-
}
133-
</CardContent>
134-
<CardFooter>
135-
</CardFooter>
136-
</Card>
137-
)
138-
139-
}
107+
<div className="flex flex-col">
108+
<span className="text-xs font-normal">TIMESTAMPS:</span>
109+
</div>
110+
<div className="text-xs text-muted-foreground">
111+
Created:{" "}
112+
{format(new Date(attestation.time * 1000), "yyyy/MM/dd HH:MM:ss")}
113+
</div>
114+
</CardDescription>
115+
</CardHeader>
116+
) : (
117+
<Skeleton className="w-[100px] h-[20px] rounded-full" />
118+
)}
119+
<CardContent>
120+
{attestation && <AttestationCardContent attestation={attestation} />}
121+
</CardContent>
122+
<CardFooter></CardFooter>
123+
</Card>
124+
);
125+
};

Diff for: apps/storybook/src/stories/attestations/AttestationFormEasSdk.stories.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { EAS_CONTRACT_ADDRESS } from "@/lib/eas/abi";
22
import {
3-
SCHEMA_FIXTURE_IS_A_FRIEND,
43
VOTE_SCHEMA_FIXTURE,
54
ZERO_BYTES,
65
ZERO_BYTES32,
76
} from "@/lib/eas/eas-test.fixture";
8-
import { createTestEthersSigner } from "@/lib/eas/ethers";
97
import { createAttestationOnchain, createEAS } from "@/lib/eas/ethers/onchain";
108
import { NO_EXPIRATION } from "@/lib/eas/request";
9+
import { createTestEthersSigner } from "@/lib/test-utils";
1110
import type { Meta, StoryObj } from "@storybook/react";
1211
import { encodeBytes32String } from "ethers";
1312
import { Address, Hex } from "viem";
@@ -35,7 +34,6 @@ const AttestationFormEasSdk = ({
3534

3635
const eas = createEAS(EAS_CONTRACT_ADDRESS, signer);
3736

38-
console.log("sdk", isOffchain);
3937
return (
4038
<AttestationForm
4139
chainId={11155111}
@@ -70,7 +68,6 @@ const AttestationFormEasSdk = ({
7068
signer,
7169
);
7270

73-
console.log("created", attestation);
7471
const { uid } = attestation;
7572
return {
7673
uids: [uid],

0 commit comments

Comments
 (0)