Skip to content

Commit

Permalink
chore: username undefined (#3318)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas Burtey <[email protected]>
  • Loading branch information
nicolasburtey and Nicolas Burtey authored Oct 11, 2023
1 parent 37ab866 commit 9750e5a
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 31 deletions.
11 changes: 0 additions & 11 deletions core/api/src/app/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,3 @@ export const hasPermissions = async (
export const getBusinessMapMarkers = async () => {
return accounts.listBusinessesForMap()
}

export const getUsernameFromWalletId = async (
walletId: WalletId,
): Promise<Username | ApplicationError> => {
const wallet = await WalletsRepository().findById(walletId)
if (wallet instanceof Error) return wallet

const account = await accounts.findById(wallet.accountId)
if (account instanceof Error) return account
return account.username
}
2 changes: 1 addition & 1 deletion core/api/src/app/payments/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const recipientDetailsFromInvoice = async <R extends WalletCurrency>(
recipientWalletDescriptors: AccountWalletDescriptors
pubkey: Pubkey
usdPaymentAmount: UsdPaymentAmount | undefined
username: Username
username: Username | undefined
userId: UserId
}
| ApplicationError
Expand Down
2 changes: 1 addition & 1 deletion core/api/src/domain/accounts/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type AccountStatusHistory = Array<{
type Account = {
readonly id: AccountId
readonly createdAt: Date
username: Username
username?: Username | undefined
defaultWalletId: WalletId
withdrawFee: Satoshis // TODO: make it optional. only save when not default value from yaml
level: AccountLevel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dedent from "dedent"

import { Accounts, Payments } from "@/app"
import { Payments } from "@/app"
import { checkedToWalletId } from "@/domain/wallets"
import { mapAndParseErrorForGqlResponse } from "@/graphql/error-map"
import { GT } from "@/graphql/index"
Expand Down Expand Up @@ -48,14 +48,6 @@ const IntraLedgerPaymentSendMutation = GT.Field<null, GraphQLPublicContextAuth>(
return { errors: [mapAndParseErrorForGqlResponse(recipientWalletIdChecked)] }
}

// TODO: confirm whether we need to check for username here
const recipientUsername = await Accounts.getUsernameFromWalletId(
recipientWalletIdChecked,
)
if (recipientUsername instanceof Error) {
return { errors: [mapAndParseErrorForGqlResponse(recipientUsername)] }
}

const status = await Payments.intraledgerPaymentSendWalletIdForBtcWallet({
recipientWalletId,
memo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dedent from "dedent"

import { Accounts, Payments } from "@/app"
import { Payments } from "@/app"
import { checkedToWalletId } from "@/domain/wallets"
import { mapAndParseErrorForGqlResponse } from "@/graphql/error-map"
import { GT } from "@/graphql/index"
Expand Down Expand Up @@ -48,14 +48,6 @@ const IntraLedgerUsdPaymentSendMutation = GT.Field<null, GraphQLPublicContextAut
return { errors: [mapAndParseErrorForGqlResponse(recipientWalletIdChecked)] }
}

// TODO: confirm whether we need to check for username here
const recipientUsername = await Accounts.getUsernameFromWalletId(
recipientWalletIdChecked,
)
if (recipientUsername instanceof Error) {
return { errors: [mapAndParseErrorForGqlResponse(recipientUsername)] }
}

const status = await Payments.intraledgerPaymentSendWalletIdForUsdWallet({
recipientWalletId,
memo,
Expand Down

0 comments on commit 9750e5a

Please sign in to comment.