Skip to content
Draft
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
10 changes: 8 additions & 2 deletions .github/workflows/vercel-deploy-engagement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ jobs:
url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@v4
- name: Enable Corepack
run: |
corepack enable
corepack install --global yarn@4.17.1
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: yarn
- name: Install Vercel CLI
run: npm install --global vercel@latest
Expand All @@ -34,5 +38,7 @@ jobs:
- run: vercel build --prod --token=${{ secrets.VERCEL_DEPLOY_TOKEN }}
working-directory: apps/engagement-app
- id: deploy
run: echo "::set-output name=url::$(vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_DEPLOY_TOKEN }})"
run: |
url="$(vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_DEPLOY_TOKEN }})"
echo "url=$url" >> "$GITHUB_OUTPUT"
working-directory: apps/engagement-app
6 changes: 5 additions & 1 deletion .github/workflows/vercel-preview-engagement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Enable Corepack
run: |
corepack enable
corepack install --global yarn@4.17.1
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: yarn
- name: Install Vercel CLI
run: npm install --global vercel@latest
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/vercel-preview-identity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Enable Corepack
run: |
corepack enable
corepack install --global yarn@4.17.1
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: yarn
- name: Install Vercel CLI
run: npm install --global vercel@latest
Expand Down
934 changes: 0 additions & 934 deletions .yarn/releases/yarn-4.6.0.cjs

This file was deleted.

2 changes: 0 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.6.0.cjs
2 changes: 1 addition & 1 deletion apps/demo-identity-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
</html>
3 changes: 3 additions & 0 deletions apps/demo-identity-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@
"sass": "^1.85.1",
"typescript": "^5.8.2",
"vite": "6.3.5"
},
"peerDependencies": {
"@farcaster/miniapp-sdk": "^0.1.8"
}
}
18 changes: 11 additions & 7 deletions apps/demo-identity-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { config } from "@tamagui/config/v3"
import { useLocation } from "react-router-dom"
import { useAccount } from "wagmi"
import { useIdentitySDK } from "@goodsdks/react-hooks"
import { sdk } from "@farcaster/miniapp-sdk"

import { VerifyButton } from "./components/VerifyButton"
import { IdentityCard } from "./components/IdentityCard"
Expand All @@ -24,6 +25,10 @@ import { SDK_ENV } from "./config"

const tamaguiConfig = createTamagui(config)

export const FARCASTER_CONFIG = {
domain: typeof window === "undefined" ? "" : window.location.host,
}

const App: React.FC = () => {
const [isSigningModalOpen, setIsSigningModalOpen] = useState(false)
const [isVerified, setIsVerified] = useState<boolean | undefined>(false)
Expand All @@ -41,6 +46,10 @@ const App: React.FC = () => {
)
const { sdk: identitySDK, loading, error } = useIdentitySDK(SDK_ENV)

useEffect(() => {
void sdk.actions.ready().catch(() => undefined)
}, [])

useEffect(() => {
const urlParams = new URLSearchParams(location.search)
const verified = urlParams.get("verified")
Expand Down Expand Up @@ -74,6 +83,7 @@ const App: React.FC = () => {
setIsVerified(isWhitelisted ?? false)
} catch (error) {
console.error("Error checking whitelist:", error)
setIsWhitelisted(false)
} finally {
setLoadingWhitelist(false)
}
Expand All @@ -89,10 +99,6 @@ const App: React.FC = () => {
}
}, [address, identitySDK, isWhitelisted, connectedAccount])

const handleVerificationSuccess = () => {
setIsVerified(true)
}

return (
<TamaguiProvider config={tamaguiConfig}>
<ScrollView
Expand Down Expand Up @@ -182,9 +188,7 @@ const App: React.FC = () => {
!isWhitelisted &&
!error ? (
<YStack alignItems="center" gap={12}>
<VerifyButton
onVerificationSuccess={handleVerificationSuccess}
/>
<VerifyButton />
<Text fontSize={14} color="$gray10">
You need to verify your identity via GoodDollar to continue.
</Text>
Expand Down
10 changes: 3 additions & 7 deletions apps/demo-identity-app/src/components/ClaimButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,21 @@ export const ClaimButton: React.FC = () => {
setError("ClaimSDK is not initialized.")
return
}
console.log("handleClaim called")

setIsClaiming(true)
setError(null)
setTxHash(null)

try {
const callBackExample = async () => {
console.log("waiting for claim for 2 seconds...")
await new Promise((resolve) => setTimeout(resolve, 2000)) // wait 2 seconds
console.log("tx start")
const txConfirm = async () => {
await new Promise((resolve) => setTimeout(resolve, 2000))
}

const tx = await sdk.claim(callBackExample)
const tx = await sdk.claim(txConfirm)
if (!tx) return

setTxHash(tx.transactionHash)
} catch (err: any) {
console.error("Claim failed:", err)
setError(err.message || "An unexpected error occurred.")
} finally {
setIsClaiming(false)
Expand Down
17 changes: 10 additions & 7 deletions apps/demo-identity-app/src/components/VerifyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { useIdentitySDK } from "@goodsdks/react-hooks"
import { useAccount } from "wagmi"
import { SDK_ENV } from "../config"

import { isInFarcasterMiniApp } from "@goodsdks/citizen-sdk"
import { FARCASTER_CONFIG } from "../App"

interface VerifyButtonProps {
onVerificationSuccess: () => void
}
Expand All @@ -16,16 +19,16 @@ export const VerifyButton: React.FC<VerifyButtonProps> = () => {
if (!identitySDK || !address) return

try {
const fvLink = await identitySDK.generateFVLink(
false,
window.location.href,
42220,
)
let callbackUrl = window.location.href

const isFarcaster = await isInFarcasterMiniApp()
if (isFarcaster) {
callbackUrl = identitySDK.generateFarcasterCallback(FARCASTER_CONFIG)
}

window.location.href = fvLink
await identitySDK.navigateToFaceVerification(callbackUrl, 42220)
} catch (error) {
console.error("Verification failed:", error)
// Handle error (e.g., show toast)
}
}

Expand Down
10 changes: 7 additions & 3 deletions apps/demo-identity-app/src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ export const SDK_ENV = "development" as const

const queryClient = new QueryClient()

const projectId = "71dd03d057d89d0af68a4c627ec59694"

const projectId = "71dd03d057d89d0af68a4c627ec59694"
const metadata = {
name: "AppKit",
description: "AppKit Example",
url: "https://example.com", // origin must match your domain & subdomain
url: "http://localhost:3000",
icons: ["https://avatars.githubusercontent.com/u/179229932"],
}

Expand Down Expand Up @@ -45,6 +44,11 @@ createAppKit({
"--w3m-color-mix-strength": 40,
"--w3m-accent": "#00BB7F",
},
allowUnsupportedChain: false,
enableWalletConnect: true,
enableInjected: true,
enableEIP6963: true,
enableCoinbase: true,
})

type ComponentProps = {
Expand Down
2 changes: 2 additions & 0 deletions apps/demo-identity-app/src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from "react"

declare namespace JSX {
interface IntrinsicElements {
"claim-button": React.DetailedHTMLProps<
Expand Down
2 changes: 1 addition & 1 deletion apps/demo-identity-app/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ export default defineConfig({
"process.browser": true,
"process.env": process.env,
},
});
});
2 changes: 1 addition & 1 deletion apps/demo-webcomponents/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export default defineConfig({
"process.browser": true,
"process.env": process.env,
},
})
})
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@
"engines": {
"node": ">=18"
},
"packageManager": "yarn@4.6.0",
"workspaces": [
"apps/*",
"packages/*"
],
"resolutions": {
"@reown/appkit": "1.7.2",
"@reown/appkit-adapter-wagmi": "1.7.2",
"@wagmi/connectors": "5.7.12",
"@openzeppelin/contracts": "5.2.0",
"@openzeppelin/contracts-upgradeable": "5.2.0",
"typescript": "5.9.3",
"viem": "2.28.x",
"wagmi": "^2.14.8"
}
"wagmi": "2.14.11"
},
"packageManager": "yarn@4.17.1"
}
25 changes: 25 additions & 0 deletions packages/citizen-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,31 @@ For Wagmi-based React projects, use the hooks exposed from `@goodsdks/react-hook

Explore the generated TypeScript definitions in `dist/` for the complete surface, including helper enums (`contractEnv`, `SupportedChains`, etc.).

## Farcaster MiniApp Support

The SDK includes support for Farcaster miniapps, which enables proper navigation and callback handling when running inside a Farcaster miniapp environment.

### Configuration

**Important**: The `FarcasterAppConfigs` in `constants.ts` are placeholder values. If you're integrating the SDK into a Farcaster miniapp, you must provide your Farcaster app ID and slug when initializing the SDK.

1. Go to the [Farcaster Developer Portal](https://warpcast.com/~/developers)
2. Register your Mini App and obtain your `appId` and `appSlug`
3. Pass these values to `IdentitySDK.init`:

```ts
const identitySDK = await IdentitySDK.init({
publicClient,
walletClient,
env: "production",
farcasterConfig: {
appId: "YOUR_APP_ID",
appSlug: "YOUR_APP_SLUG"
}
})
```

The SDK will automatically detect if it's running in a Farcaster miniapp and use Universal Links for callbacks, which ensures proper navigation back to your miniapp after face verification.
## Contract Addresses

### Celo
Expand Down
2 changes: 2 additions & 0 deletions packages/citizen-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"src"
],
"devDependencies": {
"@farcaster/miniapp-sdk": "^0.1.8",
"@repo/typescript-config": "workspace:*",
"@vitest/ui": "^4.0.18",
"typescript": "latest",
Expand All @@ -36,6 +37,7 @@
"wagmi": "latest"
},
"peerDependencies": {
"@farcaster/miniapp-sdk": "^0.1.8",
"viem": "*",
"wagmi": "*"
},
Expand Down
1 change: 1 addition & 0 deletions packages/citizen-sdk/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const Envs: Record<string, Record<string, string>> = {
},
}


export interface ContractAddresses {
identityContract: `0x${string}`
ubiContract: `0x${string}`
Expand Down
2 changes: 2 additions & 0 deletions packages/citizen-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export * from "./sdks"
export * from "./constants"
export * from "./capabilities"
export * from "./utils/triggerFaucet"
export { isInFarcasterMiniApp } from "./utils/auth"
export type { FarcasterAppConfig } from "./utils/auth"


export type {
Expand Down
1 change: 0 additions & 1 deletion packages/citizen-sdk/src/sdks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./viem-identity-sdk"
export * from "./viem-claim-sdk"
export * from "./viem-custodial-claim-sdk"
export * from "./viem-custodial-identity-sdk"
Loading
Loading