1
- import {
2
- NEXT_PUBLIC_DASHBOARD_CLIENT_ID ,
3
- NEXT_PUBLIC_IPFS_GATEWAY_URL ,
4
- } from "@/constants/public-envs" ;
1
+ import { NEXT_PUBLIC_IPFS_GATEWAY_URL } from "@/constants/public-envs" ;
5
2
import {
6
3
THIRDWEB_BRIDGE_URL ,
7
4
THIRDWEB_BUNDLER_DOMAIN ,
@@ -22,10 +19,21 @@ import {
22
19
import { getZkPaymasterData } from "thirdweb/wallets/smart" ;
23
20
import { getVercelEnv } from "../../lib/vercel-utils" ;
24
21
25
- export function getConfiguredThirdwebClient ( options : {
26
- secretKey : string | undefined ;
27
- teamId : string | undefined ;
28
- } ) : ThirdwebClient {
22
+ export function getConfiguredThirdwebClient (
23
+ options :
24
+ | {
25
+ type : "server" ;
26
+ secretKey : string ;
27
+ clientId : string | undefined ;
28
+ teamId : string | undefined ;
29
+ }
30
+ | {
31
+ type : "client" ;
32
+ clientId : string ;
33
+ secretKey : string | undefined ;
34
+ teamId : string | undefined ;
35
+ } ,
36
+ ) : ThirdwebClient {
29
37
if ( getVercelEnv ( ) !== "production" ) {
30
38
// if not on production: run this when creating a client to set the domains
31
39
setThirdwebDomains ( {
@@ -73,16 +81,30 @@ export function getConfiguredThirdwebClient(options: {
73
81
} ) ;
74
82
}
75
83
76
- return createThirdwebClient ( {
77
- teamId : options . teamId ,
78
- secretKey : options . secretKey ,
79
- clientId : NEXT_PUBLIC_DASHBOARD_CLIENT_ID ,
80
- config : {
81
- storage : {
82
- gatewayUrl : NEXT_PUBLIC_IPFS_GATEWAY_URL ,
83
- } ,
84
- } ,
85
- } ) ;
84
+ return createThirdwebClient (
85
+ // this ternary is purely for making typescript happy - both are same object
86
+ options . type === "server"
87
+ ? {
88
+ teamId : options . teamId ,
89
+ secretKey : options . secretKey ,
90
+ clientId : options . clientId ,
91
+ config : {
92
+ storage : {
93
+ gatewayUrl : NEXT_PUBLIC_IPFS_GATEWAY_URL ,
94
+ } ,
95
+ } ,
96
+ }
97
+ : {
98
+ teamId : options . teamId ,
99
+ secretKey : options . secretKey ,
100
+ clientId : options . clientId ,
101
+ config : {
102
+ storage : {
103
+ gatewayUrl : NEXT_PUBLIC_IPFS_GATEWAY_URL ,
104
+ } ,
105
+ } ,
106
+ } ,
107
+ ) ;
86
108
}
87
109
88
110
/**
0 commit comments