@@ -11,6 +11,7 @@ import {
1111 walletTableSchema ,
1212} from "../../server/schemas/wallet" ;
1313import { getWalletDetails } from "../../src/db/wallets/getWalletDetails" ;
14+ import { PrismaTransaction } from "../../src/schema/prisma" ;
1415import { env } from "../env" ;
1516import { networkResponseSchema } from "../schema" ;
1617
@@ -95,7 +96,11 @@ const cacheSdk = (
9596} ;
9697
9798const walletDataMap : Map < string , string > = new Map ( ) ;
98- const getCachedWallet = async ( walletAddress : string , chainId : number ) => {
99+ const getCachedWallet = async (
100+ walletAddress : string ,
101+ chainId : number ,
102+ pgtx ?: PrismaTransaction ,
103+ ) => {
99104 walletAddress = walletAddress . toLowerCase ( ) ;
100105 let walletData ;
101106 const cachedWallet = walletDataMap . get ( walletAddress ) ;
@@ -104,7 +109,11 @@ const getCachedWallet = async (walletAddress: string, chainId: number) => {
104109 } else {
105110 console . log ( "Checking details for address" , walletAddress ) ;
106111 // TODO: This needs to be changed...
107- walletData = await getWalletDetails ( { address : walletAddress , chainId } ) ;
112+ walletData = await getWalletDetails ( {
113+ pgtx,
114+ address : walletAddress ,
115+ chainId,
116+ } ) ;
108117 console . log ( "Received wallet data:" , walletData ) ;
109118 if ( walletData ) {
110119 walletDataMap . set ( walletAddress , JSON . stringify ( walletData ) ) ;
@@ -121,6 +130,7 @@ const THIRDWEB_API_SECRET_KEY = env.THIRDWEB_API_SECRET_KEY;
121130export const getSDK = async (
122131 chainName : ChainOrRpc ,
123132 walletAddress ?: string ,
133+ pgtx ?: PrismaTransaction ,
124134) : Promise < ThirdwebSDK > => {
125135 let walletData : Static < typeof walletTableSchema > | undefined ;
126136
@@ -158,7 +168,7 @@ export const getSDK = async (
158168 return sdk ;
159169 }
160170
161- walletData = await getCachedWallet ( walletAddress , chain . chainId ) ;
171+ walletData = await getCachedWallet ( walletAddress , chain . chainId , pgtx ) ;
162172
163173 if ( ! walletData ) {
164174 throw new Error ( `Wallet not found for address: ${ walletAddress } ` ) ;
0 commit comments