Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 0 additions & 137 deletions lib/farcaster-connector.ts

This file was deleted.

14 changes: 14 additions & 0 deletions lib/farcaster-detect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Detect whether we are running inside a Farcaster Mini App context.
* Safe to call on server (returns false) and outside Farcaster (returns false).
*/
export async function isFarcasterMiniApp(): Promise<boolean> {
if (typeof window === "undefined") return false;
try {
const { sdk } = await import("@farcaster/miniapp-sdk");
const ctx = await sdk.context;
return !!ctx;
} catch {
return false;
}
}
4 changes: 2 additions & 2 deletions lib/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { http, createConfig } from "wagmi";
import { base, baseSepolia } from "wagmi/chains";
import { injected } from "wagmi/connectors";
import { farcaster } from "./farcaster-connector";
import { farcasterMiniApp } from "@farcaster/miniapp-wagmi-connector";

export const config = createConfig({
chains: [base, baseSepolia],
connectors: [farcaster(), injected()],
connectors: [farcasterMiniApp(), injected()],
transports: {
[base.id]: http(
process.env.NEXT_PUBLIC_CHAIN_ID === "8453"
Expand Down
105 changes: 76 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.1009.0",
"@farcaster/miniapp-sdk": "^0.2.3",
"@farcaster/miniapp-wagmi-connector": "^1.1.1",
"@supabase/supabase-js": "^2.99.1",
"@tanstack/react-query": "^5.90.21",
"next": "16.1.6",
Expand Down
18 changes: 18 additions & 0 deletions public/.well-known/farcaster.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"accountAssociation": {
"header": "",
"payload": "",
"signature": ""
},
"miniapp": {
"version": "1",
"name": "PlotLink",
"iconUrl": "https://plotlink.xyz/icon.png",
"homeUrl": "https://plotlink.xyz",
"splashBackgroundColor": "#0a0a0a",
"description": "Tokenise your story from day 1. Publish plots, drive trading, earn royalties from every trade.",
"primaryCategory": "entertainment",
"tags": ["stories", "writing", "onchain", "base"],
"requiredChains": ["eip155:8453"]
}
}
Binary file added public/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/components/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useEffect, useRef, useState } from "react";
import { useAccount, useConnect, useDisconnect } from "wagmi";
import { isFarcasterMiniApp } from "../../lib/farcaster-connector";
import { isFarcasterMiniApp } from "../../lib/farcaster-detect";
import { truncateAddress } from "../../lib/utils";
import { useConnectedIdentity } from "../hooks/useConnectedIdentity";

Expand All @@ -25,7 +25,7 @@ export function ConnectWallet() {
if (autoConnectAttempted.current || isConnected) return;
autoConnectAttempted.current = true;

const farcasterConnector = connectors.find((c) => c.type === "farcaster");
const farcasterConnector = connectors.find((c) => c.type === "farcasterMiniApp");
if (!farcasterConnector) return;

farcasterConnector.isAuthorized().then((authorized) => {
Expand Down Expand Up @@ -66,7 +66,7 @@ export function ConnectWallet() {
onClick={() => {
// Use Farcaster connector only when confirmed inside a mini app
const farcasterConnector = inMiniApp
? connectors.find((c) => c.type === "farcaster")
? connectors.find((c) => c.type === "farcasterMiniApp")
: undefined;
const fallback = connectors.find((c) => c.type === "injected");
const connector = farcasterConnector ?? fallback;
Expand Down
Loading