Skip to content

Commit 1f50d7d

Browse files
authored
Add guild join prompt for first-time chat input (#30)
* feat: prompt users to join guild * fix unkey, update prompt-form * update to unkey v2
1 parent aa8ccfa commit 1f50d7d

8 files changed

Lines changed: 201 additions & 117 deletions

File tree

.env.example

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1+
NEXT_PUBLIC_ALCHEMY_API_KEY=
2+
NEXT_PUBLIC_BLOCKSCOUT_API_KEY=
3+
NEXT_PUBLIC_ETHERSCAN_API_KEY=
4+
NEXT_PUBLIC_INFURA_API_KEY=
5+
NEXT_PUBLIC_IPFS_GATEWAY=
6+
NEXT_PUBLIC_QUICKNODE_API_KEY=
7+
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
8+
NEXT_PUBLIC_TENDERLY_API_KEY=
9+
110
AUTH_GITHUB_ID=
211
AUTH_GITHUB_SECRET=
312
AUTH_REDIRECT_PROXY_URL=
413
AUTH_SECRET=
514
CRON_SECRET=
15+
UNKEY_ROOT_KEY=
16+
617
DEPLOYER_PRIVATE_KEY=
18+
719
KV_REST_API_READ_ONLY_TOKEN=
820
KV_REST_API_TOKEN=
921
KV_REST_API_URL=
1022
KV_URL=
11-
NEXT_PUBLIC_ALCHEMY_API_KEY=
12-
NEXT_PUBLIC_BLOCKSCOUT_API_KEY=
13-
NEXT_PUBLIC_ETHERSCAN_API_KEY=
14-
NEXT_PUBLIC_INFURA_API_KEY=
15-
NEXT_PUBLIC_IPFS_GATEWAY=
16-
NEXT_PUBLIC_QUICKNODE_API_KEY=
17-
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
23+
1824
OPENAI_API_KEY=
25+
STABILITY_API_KEY=
26+
XAI_API_KEY=
27+
1928
PINATA_API_KEY=
2029
PINATA_API_SECRET=
2130
PINATA_JWT=
22-
STABILITY_API_KEY=
23-
XAI_API_KEY=
24-
UNKEY_COMPLETIONS_API_ID=
25-
UNKEY_CONTRACTS_API_ID=
26-
UNKEY_CONTRACTS_API_KEY=
27-
NEXT_PUBLIC_TENDERLY_API_KEY=

app/api/api-docs/route.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { ApiReference } from "@scalar/nextjs-api-reference"
22
import openApiSpec from "@/public/openapi.json"
33

4-
const isProduction = process.env.NODE_ENV === "production"
5-
const UNKEY_CONTRACTS_API_KEY = process.env.UNKEY_CONTRACTS_API_KEY
6-
74
const config = {
85
theme: "saturn" as const,
96
metaData: {
@@ -13,7 +10,7 @@ const config = {
1310
authentication: {
1411
http: {
1512
bearer: {
16-
token: isProduction ? undefined : UNKEY_CONTRACTS_API_KEY,
13+
token: undefined,
1714
},
1815
basic: {
1916
username: "",

app/api/v1/completions/route.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { track } from "@vercel/analytics/server"
44
import { generateText, streamText } from "ai"
55
import { NextResponse } from "next/server"
66

7-
const UNKEY_COMPLETIONS_API_ID = process.env.UNKEY_COMPLETIONS_API_ID
7+
const UNKEY_ROOT_KEY = process.env.UNKEY_ROOT_KEY
8+
9+
if (!UNKEY_ROOT_KEY) {
10+
throw new Error("UNKEY_ROOT_KEY is not set")
11+
}
812

913
export const maxDuration = 30
1014

@@ -18,7 +22,7 @@ export const POST = withUnkey(
1822
}
1923

2024
// Validate API key
21-
if (!req.unkey?.valid) {
25+
if (!req.unkey?.data?.valid) {
2226
return new NextResponse("unauthorized get api key at https://t.me/w3gptai", {
2327
status: 403,
2428
headers,
@@ -37,13 +41,12 @@ export const POST = withUnkey(
3741
})
3842
}
3943

40-
const { keyId = "unknown_key", remaining = 0, ownerId = "unknown_owner" } = req.unkey
44+
const { keyId = "unknown_key", credits = 0, identity } = req.unkey.data
4145

4246
track("completions_request", {
43-
apiId: UNKEY_COMPLETIONS_API_ID,
4447
keyId,
45-
ownerId,
46-
remaining,
48+
externalId: identity?.externalId || "unknown_external_id",
49+
credits,
4750
stream,
4851
})
4952

@@ -83,8 +86,7 @@ export const POST = withUnkey(
8386
status: 403,
8487
})
8588
},
86-
disableTelemetry: true,
87-
apiId: UNKEY_COMPLETIONS_API_ID,
89+
rootKey: UNKEY_ROOT_KEY,
8890
},
8991
)
9092

app/api/v1/contracts/deploy/route.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { z } from "zod"
1010
import { compileContract } from "@/lib/actions/deploy-contract"
1111
import { deployContract } from "@/lib/solidity/deploy"
1212

13-
const UNKEY_CONTRACTS_API_ID = process.env.UNKEY_CONTRACTS_API_ID
13+
const UNKEY_ROOT_KEY = process.env.UNKEY_ROOT_KEY
1414

15-
if (!UNKEY_CONTRACTS_API_ID) {
16-
throw new Error("UNKEY_CONTRACTS_API_ID is not set")
15+
if (!UNKEY_ROOT_KEY) {
16+
throw new Error("UNKEY_ROOT_KEY is not set")
1717
}
1818

1919
export const maxDuration = 60
@@ -44,7 +44,7 @@ export const POST = withUnkey(
4444
}
4545

4646
// Validate API key
47-
if (!req.unkey?.valid) {
47+
if (!req.unkey?.data?.valid) {
4848
return new NextResponse("unauthorized get api key at https://t.me/w3gptai", {
4949
status: 403,
5050
headers,
@@ -63,14 +63,13 @@ export const POST = withUnkey(
6363
})
6464
}
6565

66-
const { keyId = "unknown_key", remaining = 0, ownerId = "unknown_owner" } = req.unkey
66+
const { keyId = "unknown_key", credits = 0, identity } = req.unkey.data
6767

6868
// Track analytics
6969
track("contract_deploy_request", {
70-
apiId: UNKEY_CONTRACTS_API_ID,
7170
keyId,
72-
ownerId,
73-
remaining,
71+
externalId: identity?.externalId || "unknown_external_id",
72+
credits,
7473
})
7574

7675
// Generate contract source code
@@ -220,8 +219,7 @@ export const POST = withUnkey(
220219
status: 403,
221220
})
222221
},
223-
disableTelemetry: true,
224-
apiId: UNKEY_CONTRACTS_API_ID,
222+
rootKey: UNKEY_ROOT_KEY,
225223
},
226224
)
227225

bun.lock

Lines changed: 4 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)