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" ;
52import {
63 THIRDWEB_BRIDGE_URL ,
74 THIRDWEB_BUNDLER_DOMAIN ,
@@ -22,10 +19,21 @@ import {
2219import { getZkPaymasterData } from "thirdweb/wallets/smart" ;
2320import { getVercelEnv } from "../../lib/vercel-utils" ;
2421
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 {
2937 if ( getVercelEnv ( ) !== "production" ) {
3038 // if not on production: run this when creating a client to set the domains
3139 setThirdwebDomains ( {
@@ -73,16 +81,30 @@ export function getConfiguredThirdwebClient(options: {
7381 } ) ;
7482 }
7583
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+ ) ;
86108}
87109
88110/**
0 commit comments