-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add transaction builder functions for interacting with Morpho vaults #1852
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
export function useEarnContext() { | ||
const context = useContext(EarnContext); | ||
if (!context) { | ||
throw new Error('useEarnContext must be used within an EarnProvider'); | ||
} | ||
return context; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our pattern has not been to throw if useComponentContext
s have been used outside of their providers. Perhaps that's bad practice, but it's useful in certain cases (eg. if you want to attempt to use a context, and if you get back values use them, and if not source them from elsewhere).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're not throwing these errors in our context hooks, that seems like a code smell. It's the standard way of doing it for pretty much all major libraries.
We also do this in:
useNFTLifecycleContext
useTheme
useBuyContext
useCheckoutContext
useTransactionContext
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should include this in all providers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as I know, wallet is the exception so it will silently fail on an unconnected wallet button
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a big issue that we don't throw in useOnchainKit
especially
src/earn/utils/deposit.ts
Outdated
tokenAddress: Address; | ||
amount: bigint; | ||
receiverAddress: Address; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add descriptions for each of theses plz?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
export function useEarnContext() { | ||
const context = useContext(EarnContext); | ||
if (!context) { | ||
throw new Error('useEarnContext must be used within an EarnProvider'); | ||
} | ||
return context; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the identity components are set up so that the provider is optional, same as wallet |
What changed? Why?
Notes to reviewers
How has it been tested?