11import  prisma  from  'prisma-local/clientInstance' 
2- import  {  Prisma ,  Transaction ,   ClientPaymentStatus  }  from  '@prisma/client' 
3- import  {  RESPONSE_MESSAGES ,  USD_QUOTE_ID ,  CAD_QUOTE_ID ,  N_OF_QUOTES ,  UPSERT_TRANSACTION_PRICES_ON_DB_TIMEOUT ,  SupportedQuotesType ,  NETWORK_IDS ,  NETWORK_IDS_FROM_SLUGS ,   PRICES_CONNECTION_BATCH_SIZE ,  PRICES_CONNECTION_TIMEOUT  }  from  'constants/index' 
2+ import  {  Prisma ,  Transaction  }  from  '@prisma/client' 
3+ import  {  RESPONSE_MESSAGES ,  USD_QUOTE_ID ,  CAD_QUOTE_ID ,  N_OF_QUOTES ,  UPSERT_TRANSACTION_PRICES_ON_DB_TIMEOUT ,  SupportedQuotesType ,  NETWORK_IDS ,  PRICES_CONNECTION_BATCH_SIZE ,  PRICES_CONNECTION_TIMEOUT  }  from  'constants/index' 
44import  {  fetchAddressBySubstring ,  fetchAddressById ,  fetchAddressesByPaybuttonId ,  addressExists  }  from  'services/addressService' 
55import  {  AllPrices ,  QuoteValues ,  fetchPricesForNetworkAndTimestamp ,  flattenTimestamp  }  from  'services/priceService' 
66import  _  from  'lodash' 
@@ -9,8 +9,6 @@ import { SimplifiedTransaction } from 'ws-service/types'
99import  {  OpReturnData ,  parseAddress  }  from  'utils/validators' 
1010import  {  generatePaymentFromTxWithInvoices  }  from  'redis/paymentCache' 
1111import  {  ButtonDisplayData ,  Payment  }  from  'redis/types' 
12- import  {  v4  as  uuidv4  }  from  'uuid' 
13- import  {  multiBlockchainClient  }  from  'services/chronikService' 
1412
1513export  function  getTransactionValue  ( transaction : TransactionWithPrices  |  TransactionsWithPaybuttonsAndPrices  |  SimplifiedTransaction ) : QuoteValues  { 
1614  const  ret : QuoteValues  =  { 
@@ -976,53 +974,3 @@ export const fetchDistinctPaymentYearsByUser = async (userId: string): Promise<n
976974
977975  return  years . map ( y  =>  y . year ) 
978976} 
979- 
980- export  const  generatePaymentId  =  async  ( address : string ,  amount ?: Prisma . Decimal ) : Promise < string >  =>  { 
981-   const  rawUUID  =  uuidv4 ( ) 
982-   const  cleanUUID  =  rawUUID . replace ( / - / g,  '' ) 
983-   const  status  =  'PENDING'  as  ClientPaymentStatus 
984-   address  =  parseAddress ( address ) 
985-   const  prefix  =  address . split ( ':' ) [ 0 ] . toLowerCase ( ) 
986-   const  networkId  =  NETWORK_IDS_FROM_SLUGS [ prefix ] 
987-   const  isAddressRegistered  =  await  addressExists ( address ) 
988- 
989-   const  clientPayment  =  await  prisma . clientPayment . create ( { 
990-     data : { 
991-       address : { 
992-         connectOrCreate : { 
993-           where : {  address } , 
994-           create : { 
995-             address, 
996-             networkId
997-           } 
998-         } 
999-       } , 
1000-       paymentId : cleanUUID , 
1001-       status, 
1002-       amount
1003-     } , 
1004-     include : { 
1005-       address : true 
1006-     } 
1007-   } ) 
1008- 
1009-   if  ( ! isAddressRegistered )  { 
1010-     void  multiBlockchainClient . syncAndSubscribeAddresses ( [ clientPayment . address ] ) 
1011-   } 
1012- 
1013-   return  clientPayment . paymentId 
1014- } 
1015- 
1016- export  const  updateClientPaymentStatus  =  async  ( paymentId : string ,  status : ClientPaymentStatus ) : Promise < void >  =>  { 
1017-   await  prisma . clientPayment . update ( { 
1018-     where : {  paymentId } , 
1019-     data : {  status } 
1020-   } ) 
1021- } 
1022- 
1023- export  const  getClientPayment  =  async  ( paymentId : string ) : Promise < Prisma . ClientPaymentGetPayload < {  include : {  address : true  }  } >  |  null >  =>  { 
1024-   return  await  prisma . clientPayment . findUnique ( { 
1025-     where : {  paymentId } , 
1026-     include : {  address : true  } 
1027-   } ) 
1028- } 
0 commit comments