Skip to content
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

Merged
merged 12 commits into from
Jan 22, 2025

Conversation

dschlabach
Copy link
Contributor

What changed? Why?

Notes to reviewers

How has it been tested?

Copy link

vercel bot commented Jan 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
onchainkit-coverage ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2025 6:25pm
onchainkit-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2025 6:25pm
onchainkit-routes ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2025 6:25pm

Comment on lines +24 to +30
export function useEarnContext() {
const context = useContext(EarnContext);
if (!context) {
throw new Error('useEarnContext must be used within an EarnProvider');
}
return context;
}
Copy link
Contributor

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 useComponentContexts 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).

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

the providers that do not currently do this are:
OnchainKitProvider
image

IdentityProvider
image

WalletProvider
image

can y'all think of a reason we wouldn't want to throw in these cases? if not I can add

Copy link
Contributor Author

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

tokenAddress: Address;
amount: bigint;
receiverAddress: Address;
};
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +24 to +30
export function useEarnContext() {
const context = useContext(EarnContext);
if (!context) {
throw new Error('useEarnContext must be used within an EarnProvider');
}
return context;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

the providers that do not currently do this are:
OnchainKitProvider
image

IdentityProvider
image

WalletProvider
image

can y'all think of a reason we wouldn't want to throw in these cases? if not I can add

@alessey
Copy link
Contributor

alessey commented Jan 22, 2025

looks like the identity components are set up so that the provider is optional, same as wallet

@dschlabach dschlabach merged commit 8311826 into main Jan 22, 2025
16 checks passed
@dschlabach dschlabach deleted the dms/earn-provider branch January 22, 2025 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants