@@ -10,10 +10,10 @@ import { z } from "zod"
1010import { compileContract } from "@/lib/actions/deploy-contract"
1111import { 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
1919export 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
0 commit comments