@@ -12,6 +12,8 @@ import type {
1212} from '../../types/admin.js' ;
1313import { PaymentAccountService } from '../../services/api/payment-account.js' ;
1414import { CheqdNetwork } from '@cheqd/sdk' ;
15+ import { LocalStore } from '../../database/cache/store.js' ;
16+ import { PaymentAccountEntity } from '../../database/entities/payment.account.entity.js' ;
1517
1618dotenv . config ( ) ;
1719
@@ -73,16 +75,23 @@ export class OrganisationController {
7375 email,
7476 description,
7577 } ) ;
76- const paymentAccount = await PaymentAccountService . instance . find ( { customer : customer } ) ;
78+
79+ const cachedAccounts = LocalStore . instance . getCustomerAccounts ( response . locals . customer . customerId ) ;
80+ let paymentAccounts : PaymentAccountEntity [ ] ;
81+ if ( cachedAccounts ?. length == 2 ) {
82+ paymentAccounts = cachedAccounts ;
83+ } else {
84+ paymentAccounts = await PaymentAccountService . instance . find ( { customer : response . locals . customer } ) ;
85+ }
7786
78- if ( ! customer || paymentAccount . length === 0 ) {
87+ if ( ! customer || paymentAccounts . length === 0 ) {
7988 response . status ( StatusCodes . NOT_FOUND ) . json ( {
8089 error : 'Customer for updating not found' ,
8190 } satisfies AdminOrganisationUpdateUnsuccessfulResponseBody ) ;
8291 }
8392
84- const testnetAddress = paymentAccount . find ( ( acc ) => acc . namespace === CheqdNetwork . Testnet ) ?. address ;
85- const mainnetAddress = paymentAccount . find ( ( acc ) => acc . namespace === CheqdNetwork . Mainnet ) ?. address ;
93+ const testnetAddress = paymentAccounts . find ( ( acc ) => acc . namespace === CheqdNetwork . Testnet ) ?. address ;
94+ const mainnetAddress = paymentAccounts . find ( ( acc ) => acc . namespace === CheqdNetwork . Mainnet ) ?. address ;
8695
8796 return response . status ( StatusCodes . OK ) . json ( {
8897 name : customer . name ,
0 commit comments