@@ -301,7 +301,9 @@ const performApiCall = (network: string): boolean => {
301301
302302const PRO_API = "https://api.jiffyscan.xyz"
303303const DEV_API = "https://api-dev.jiffyscan.xyz"
304- const API_URL = process . env . ENV === 'production' ? PRO_API : DEV_API ;
304+ const API_URL = process . env . NEXT_PUBLIC_APP_ENV === 'production' ? PRO_API : DEV_API ;
305+ const X_API_Key = process . env . NEXT_PUBLIC_X_API_KEY ;
306+
305307
306308console . log ( API_URL )
307309
@@ -316,6 +318,15 @@ export const showToast = (toast: any, message: string, type?: string) => {
316318 pauseOnHover : true ,
317319 theme : 'colored' ,
318320 } ) ;
321+ } else if ( type == 'success' ) {
322+ toast . success ( message , {
323+ position : 'bottom-left' ,
324+ autoClose : 5000 ,
325+ hideProgressBar : false ,
326+ closeOnClick : true ,
327+ pauseOnHover : true ,
328+ theme : 'colored' ,
329+ } ) ;
319330 } else {
320331 toast . error ( message , {
321332 position : 'bottom-left' ,
@@ -810,7 +821,6 @@ export const getPayMasterDetails = async (
810821 }
811822 return data . paymasterDetail as PayMasterActivity ;
812823 }
813-
814824 return { } as PayMasterActivity ;
815825} ;
816826export const getPoweredBy = async ( beneficiary : string , paymaster : string , toast : any ) : Promise < PoweredBy > => {
@@ -923,7 +933,6 @@ export const getBundleDetails = async (
923933 if ( Object . keys ( data . bundleDetails ) . length == 0 ) {
924934 showToast ( toast , 'Error fetching data' ) ;
925935 }
926-
927936 return data . bundleDetails as Bundle ;
928937 }
929938 return { } as Bundle ;
@@ -963,3 +972,41 @@ export const getBundlerDetails = async (
963972 }
964973 return { } as Bundle ;
965974} ;
975+
976+
977+
978+ export const fetchAPIKeyList = async ( Authorization :string , sub :string ) => {
979+ let config = {
980+ method : 'get' ,
981+ maxBodyLength : Infinity ,
982+ url : `${ API_URL } /user/getxapikey?usersub=${ sub } ` ,
983+ headers : {
984+ Authorization : Authorization ,
985+ 'x-api-key' : X_API_Key ,
986+ } ,
987+ } ;
988+ return await axios . request ( config )
989+ }
990+
991+ export const createAPIKey = async ( Authorization :string , toast :any ) => {
992+ let config = {
993+ method : 'post' ,
994+ maxBodyLength : Infinity ,
995+ url : `${ API_URL } /user/createxapikey` ,
996+ headers : {
997+ Authorization,
998+ 'x-api-key' : X_API_Key ,
999+ } ,
1000+ } ;
1001+ try {
1002+ return await axios . request ( config ) . then ( ( ) => {
1003+ showToast ( toast , `API Key Created SuccessFully` , "success" ) ;
1004+ } ) ;
1005+ } catch ( error : any ) {
1006+ if ( error . request ) {
1007+ showToast ( toast , `No response received, ${ error . request } ` ) ;
1008+ } else {
1009+ console . error ( 'Error:' , error . message ) ;
1010+ }
1011+ }
1012+ } ;
0 commit comments