Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
stephancill committed Jan 8, 2025
2 parents 441df48 + ae86c93 commit e5f2235
Show file tree
Hide file tree
Showing 32 changed files with 805 additions and 330 deletions.
7 changes: 7 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# docs

## 0.3.12

### Patch Changes

- Updated dependencies [0e7244d]
- [email protected]

## 0.3.11

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.3.11",
"version": "0.3.12",
"type": "module",
"private": true,
"scripts": {
Expand All @@ -9,7 +9,7 @@
"preview": "vocs preview"
},
"dependencies": {
"frames.js": "0.21.0",
"frames.js": "0.21.1",
"lucide-react": "^0.372.0",
"next": "14.1.4",
"react": "^18.2.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/debugger/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @frames.js/debugger

## 0.4.1

### Patch Changes

- 0e7244d: feat: farcaster v2 sign in and libs update

## 0.4.0

### Minor Changes
Expand Down
17 changes: 17 additions & 0 deletions packages/debugger/app/client-info/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { z } from "zod";

export function GET() {
return Response.json(
{
fid: z.coerce
.number()
.int()
.parse(process.env.FARCASTER_DEVELOPER_FID || "-1"),
},
{
headers: {
"Cache-Control": "no-store",
},
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import {
DialogTitle,
} from "@/components/ui/dialog";
import { useAccount, useSignMessage, useSwitchChain } from "wagmi";
import { FormEvent, useCallback, useState } from "react";
import { FormEvent, useCallback, useRef, useState } from "react";
import { CopyIcon, CopyCheckIcon, CopyXIcon, Loader2Icon } from "lucide-react";
import { z } from "zod";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { useFarcasterIdentity } from "../hooks/useFarcasterIdentity";
Expand All @@ -28,6 +29,7 @@ type FarcasterDomainAccountAssociationDialogProps = {
export function FarcasterDomainAccountAssociationDialog({
onClose,
}: FarcasterDomainAccountAssociationDialogProps) {
const domainInputRef = useRef<HTMLInputElement>(null);
const copyCompact = useCopyToClipboard();
const copyJSON = useCopyToClipboard();
const account = useAccount();
Expand All @@ -44,7 +46,7 @@ export function FarcasterDomainAccountAssociationDialog({
async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();

const data = new FormData(event.currentTarget);
const data = Object.fromEntries(new FormData(event.currentTarget));

try {
if (farcasterSigner.signer?.status !== "approved") {
Expand All @@ -55,12 +57,36 @@ export function FarcasterDomainAccountAssociationDialog({
throw new Error("Account address is not available");
}

const domain = data.get("domain");
const parser = z.object({
domain: z
.preprocess((val) => {
if (typeof val === "string") {
// prepend with prefix because normally it is the domain but we want to validate
// it is in valid format
return `http://${val}`;
}

if (typeof domain !== "string" || !domain) {
throw new Error("Domain is required");
return val;
}, z.string().url("Invalid domain"))
// remove the protocol prefix
.transform((val) => val.substring(7)),
});

const parseResult = parser.safeParse(data);

if (!parseResult.success) {
parseResult.error.errors.map((error) => {
domainInputRef.current?.setCustomValidity(error.message);
});

event.currentTarget.reportValidity();

return;
}

domainInputRef.current?.setCustomValidity("");
event.currentTarget.reportValidity();

setIsGenerating(true);

await switchChainAsync({
Expand All @@ -69,8 +95,9 @@ export function FarcasterDomainAccountAssociationDialog({

const result = await sign({
fid: farcasterSigner.signer.fid,
payload:
constructJSONFarcasterSignatureAccountAssociationPaylod(domain),
payload: constructJSONFarcasterSignatureAccountAssociationPaylod(
parseResult.data.domain
),
signer: {
type: "custody",
custodyAddress: account.address,
Expand Down Expand Up @@ -117,15 +144,25 @@ export function FarcasterDomainAccountAssociationDialog({
<DialogTitle>Domain Account Association</DialogTitle>
</DialogHeader>
{!associationResult && (
<form id="domain-account-association-form" onSubmit={handleSubmit}>
<form
className="flex flex-col gap-2"
id="domain-account-association-form"
onSubmit={handleSubmit}
noValidate
>
<Label htmlFor="domain">Domain</Label>
<Input
id="domain"
name="domain"
pattern="^.+\..+$"
required
type="text"
ref={domainInputRef}
/>
<span className="text-muted-foreground text-sm">
A domain of your frame, e.g. for https://framesjs.org the domain
is framesjs.org, for http://localhost:3000 the domain is
localhost.
</span>
</form>
)}
{associationResult && (
Expand Down
Loading

0 comments on commit e5f2235

Please sign in to comment.