Skip to content

feat: add lnurlp for external wallet#341

Open
heyolaniran wants to merge 4 commits intolnflash:mainfrom
heyolaniran:feature/external-wallet-lnurl
Open

feat: add lnurlp for external wallet#341
heyolaniran wants to merge 4 commits intolnflash:mainfrom
heyolaniran:feature/external-wallet-lnurl

Conversation

@heyolaniran
Copy link
Copy Markdown
Contributor

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

  • Unit Tests: Describe tested components or logic
  • Integration Tests: State management or system interaction
  • Manual Testing: End-to-end user journey or QA notes

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.
Copy link
Copy Markdown
Contributor

@brh28 brh28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple suggested changes, but overall looks good


if (wallet instanceof Error) {
return {
errors: [mapAndParseErrorForGqlResponse(wallet)],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 })
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, I made an update to improve readability on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants