feat: add lnurlp for external wallet#341
Conversation
this commit create a new mutation to update if its exists or to create a new external lnurl for flash wallets and introduces a new external wallet primitive type.
brh28
left a comment
There was a problem hiding this comment.
a couple suggested changes, but overall looks good
|
|
||
| if (wallet instanceof Error) { | ||
| return { | ||
| errors: [mapAndParseErrorForGqlResponse(wallet)], |
There was a problem hiding this comment.
personally, I've had issues with this function as it often doesn't catch new errors we introduce and the responses aren't what I'm expecting. I've started by-passing this and mapping directly to the Apollo errors. Example:
const checkedAccountId = checkedToAccountUuid(accountId)
if (checkedAccountId instanceof Error) return apolloErrorResponse(new InputValidationError({ message: "Invalid accountId" }))
If it's working expected, no issue with me but I am curious what the response looks like
There was a problem hiding this comment.
oh i see, here instead of generic message for all types of errors we can have, it takes the applicationError then convert it to a custom ApolloError with a message based on the error type.
There was a problem hiding this comment.
Yeah, I like the idea of a wrapper class that catches errors as a sort of safety net, but I've had some issues with the current implementation so have been leaning towards more proactive error handling
| if (checkedLnurl instanceof Error) return checkedLnurl | ||
|
|
||
|
|
||
| return WalletsRepository().upsertExternal({ accountId, lnurlp: checkedLnurl }) |
There was a problem hiding this comment.
Suggestion: Move all the hardcoded values as arguments to this function
For example:
WalletsRepo.upsertExternal({
accountId,
WalletCurrency.BTC,
lnurlp
})
This wouldn't change any functionality today, but makes the code easier to read and would make the function more reusable in the future
There was a problem hiding this comment.
you are right, I made an update to improve readability on this.
this commit create a new mutation to update if its exists or to create a new external lnurl for flash wallets and introduces a new external wallet primitive type.
🧪 Testing Coverage