@@ -380,43 +380,6 @@ export function useAccountCredits() {
380380 } ) ;
381381}
382382
383- async function getWalletUsage ( args : {
384- clientId : string ;
385- from ?: Date ;
386- to ?: Date ;
387- period ?: "day" | "week" | "month" | "year" | "all" ;
388- } ) {
389- const { clientId, from, to, period } = args ;
390-
391- const searchParams = new URLSearchParams ( ) ;
392- searchParams . append ( "clientId" , clientId ) ;
393- if ( from ) {
394- searchParams . append ( "from" , from . toISOString ( ) ) ;
395- }
396- if ( to ) {
397- searchParams . append ( "to" , to . toISOString ( ) ) ;
398- }
399- if ( period ) {
400- searchParams . append ( "period" , period ) ;
401- }
402- const res = await fetch (
403- `${ THIRDWEB_ANALYTICS_API_HOST } /v1/wallets?${ searchParams . toString ( ) } ` ,
404- {
405- method : "GET" ,
406- headers : {
407- "Content-Type" : "application/json" ,
408- } ,
409- } ,
410- ) ;
411- const json = await res . json ( ) ;
412-
413- if ( res . status !== 200 ) {
414- throw new Error ( json . message ) ;
415- }
416-
417- return json . data ;
418- }
419-
420383async function getUserOpUsage ( args : {
421384 clientId : string ;
422385 from ?: Date ;
@@ -454,43 +417,6 @@ async function getUserOpUsage(args: {
454417 return json . data ;
455418}
456419
457- export async function getInAppWalletUsage ( args : {
458- clientId : string ;
459- from ?: Date ;
460- to ?: Date ;
461- period ?: "day" | "week" | "month" | "year" | "all" ;
462- } ) {
463- const { clientId, from, to, period } = args ;
464-
465- const searchParams = new URLSearchParams ( ) ;
466- searchParams . append ( "clientId" , clientId ) ;
467- if ( from ) {
468- searchParams . append ( "from" , from . toISOString ( ) ) ;
469- }
470- if ( to ) {
471- searchParams . append ( "to" , to . toISOString ( ) ) ;
472- }
473- if ( period ) {
474- searchParams . append ( "period" , period ) ;
475- }
476- const res = await fetch (
477- `${ THIRDWEB_ANALYTICS_API_HOST } /v1/wallets/in-app?${ searchParams . toString ( ) } ` ,
478- {
479- method : "GET" ,
480- headers : {
481- "Content-Type" : "application/json" ,
482- } ,
483- } ,
484- ) ;
485- const json = await res ?. json ( ) ;
486-
487- if ( ! res || res . status !== 200 ) {
488- throw new Error ( json . message ) ;
489- }
490-
491- return json . data ;
492- }
493-
494420export function useUserOpUsageAggregate ( args : {
495421 clientId : string ;
496422 from ?: Date ;
@@ -574,63 +500,6 @@ export function useUserOpUsagePeriod(args: {
574500 } ) ;
575501}
576502
577- export function useWalletUsageAggregate ( args : {
578- clientId : string ;
579- from ?: Date ;
580- to ?: Date ;
581- } ) {
582- const { clientId, from, to } = args ;
583- const { user, isLoggedIn } = useLoggedInUser ( ) ;
584-
585- return useQuery ( {
586- queryKey : accountKeys . walletStats (
587- user ?. address as string ,
588- clientId as string ,
589- from ?. toISOString ( ) || "" ,
590- to ?. toISOString ( ) || "" ,
591- "all" ,
592- ) ,
593- queryFn : async ( ) => {
594- return getWalletUsage ( {
595- clientId,
596- from,
597- to,
598- period : "all" ,
599- } ) ;
600- } ,
601- enabled : ! ! clientId && ! ! user ?. address && isLoggedIn ,
602- } ) ;
603- }
604-
605- export function useWalletUsagePeriod ( args : {
606- clientId : string ;
607- from ?: Date ;
608- to ?: Date ;
609- period : "day" | "week" | "month" | "year" ;
610- } ) {
611- const { clientId, from, to, period } = args ;
612- const { user, isLoggedIn } = useLoggedInUser ( ) ;
613-
614- return useQuery ( {
615- queryKey : accountKeys . walletStats (
616- user ?. address as string ,
617- clientId as string ,
618- from ?. toISOString ( ) || "" ,
619- to ?. toISOString ( ) || "" ,
620- period ,
621- ) ,
622- queryFn : async ( ) => {
623- return getWalletUsage ( {
624- clientId,
625- from,
626- to,
627- period,
628- } ) ;
629- } ,
630- enabled : ! ! clientId && ! ! user ?. address && isLoggedIn ,
631- } ) ;
632- }
633-
634503export function useUpdateAccount ( ) {
635504 const { user } = useLoggedInUser ( ) ;
636505 const queryClient = useQueryClient ( ) ;
0 commit comments