Skip to content

Commit

Permalink
fix: change public name to first and last name
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosp1011 committed Dec 9, 2024
1 parent 893f632 commit 0b5131f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
15 changes: 11 additions & 4 deletions packages/wallet/backend/src/rafiki/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ export class RafikiService implements IRafikiService {
)
const walletAddresses =
await this.walletAddressService.getByIds(walletAddressIds)
senders = walletAddresses.map((wa) => wa.publicName).join(', ')
senders = walletAddresses
.filter((wa) => wa.account?.user)
.map((wa) => `${wa.account.user.firstName} ${wa.account.user.lastName}`)
.join(', ')
} catch (e) {
this.logger.warn(
'Error on getting outgoing payments by incoming payment',
Expand Down Expand Up @@ -292,20 +295,24 @@ export class RafikiService implements IRafikiService {
return
}

let receiverWA
let secondParty
try {
const receiver = await this.rafikiClient.getReceiverById(wh.data.receiver)
receiverWA = await this.walletAddressService.getExternalWalletAddress(
const receiverWA = await this.walletAddressService.getByUrl(
receiver.walletAddressUrl
)

if (receiverWA?.account?.user) {
secondParty = `${receiverWA.account.user.firstName} ${receiverWA.account.user.lastName}`
}
} catch (e) {
this.logger.warn('Error on getting receiver wallet address', e)
}

await this.transactionService.createOutgoingTransaction(
wh.data,
walletAddress,
receiverWA
secondParty
)

await this.rafikiClient.depositLiquidity(wh.id)
Expand Down
5 changes: 2 additions & 3 deletions packages/wallet/backend/src/transaction/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { WalletAddress } from '@/walletAddress/model'
import { Account } from '@/account/model'
import { CardService } from '@/card/service'
import NodeCache from 'node-cache'
import { WalletAddressOP } from '@wallet/shared'

const FETCHING_TRANSACTIONS_KEY = 'FETCHING_TRANSACTIONS'
type ListAllTransactionsInput = {
Expand Down Expand Up @@ -226,7 +225,7 @@ export class TransactionService implements ITransactionService {
async createOutgoingTransaction(
params: OutgoingPayment,
walletAddress: WalletAddress,
receiverWA?: WalletAddressOP
secondParty?: string
) {
const existentTransaction = await Transaction.query().findOne({
paymentId: params.id
Expand All @@ -245,7 +244,7 @@ export class TransactionService implements ITransactionService {
type: 'OUTGOING',
status: 'PENDING',
description: params.metadata?.description,
secondParty: receiverWA?.publicName
secondParty
})
}
}
12 changes: 11 additions & 1 deletion packages/wallet/backend/src/walletAddress/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,18 @@ export class WalletAddressService implements IWalletAddressService {
}

async getByIds(ids: string[]): Promise<WalletAddress[]> {
const walletAddresses = await WalletAddress.query().whereIn('id', ids)
const walletAddresses = await WalletAddress.query()
.whereIn('id', ids)
.withGraphFetched('account.[user]')

return walletAddresses
}

async getByUrl(url: string): Promise<WalletAddress | undefined> {
const walletAddress = await WalletAddress.query()
.findOne({ url })
.withGraphFetched('account.[user]')

return walletAddress
}
}

0 comments on commit 0b5131f

Please sign in to comment.