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: useTransfers hook [OTE-853] #1137

Merged
merged 11 commits into from
Oct 18, 2024
Merged

Conversation

yogurtandjam
Copy link
Contributor

@yogurtandjam yogurtandjam commented Oct 14, 2024

Adds usetransfers hook that takes the place of abacus state.

Some cleanup around the native chain address variable.
The native chain address can be represented as either {chain_name}_native (skip API response + requests) and 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE (cosmJS + wagmi response/requests). We need to account for both now

@yogurtandjam yogurtandjam requested a review from a team as a code owner October 14, 2024 21:54
Copy link

linear bot commented Oct 14, 2024

Copy link

vercel bot commented Oct 14, 2024

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

Name Status Preview Comments Updated (UTC)
v4-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 18, 2024 5:51pm
v4-testnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 18, 2024 5:51pm

Copy link
Contributor

@tinaszheng tinaszheng left a comment

Choose a reason for hiding this comment

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

nice work jeremy!

src/constants/cctp.ts Outdated Show resolved Hide resolved
src/constants/transfers.ts Outdated Show resolved Hide resolved
src/constants/transfers.ts Outdated Show resolved Hide resolved
Comment on lines 97 to 105
const defaultTokenDenom = cctpToken?.denom ?? nativeChainToken?.denom ?? assets[0]?.denom;
return defaultTokenDenom;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const defaultTokenDenom = cctpToken?.denom ?? nativeChainToken?.denom ?? assets[0]?.denom;
return defaultTokenDenom;
return cctpToken?.denom ?? nativeChainToken?.denom ?? assets[0]?.denom;

maybe leave a comment about why assets[0] would be valid here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh forgot to add a response here:

  • added the comment!
  • personally prefer to keep declaration and return value separate for code that's in development, makes things slightly more convenient to debug. down to roll into a capstone PR and add a comment though

src/hooks/transfers/useTransfers.tsx Outdated Show resolved Hide resolved
src/hooks/transfers/useTransfers.tsx Outdated Show resolved Hide resolved
src/hooks/transfers/useTransfers.tsx Outdated Show resolved Hide resolved
src/hooks/transfers/useTransfers.tsx Outdated Show resolved Hide resolved
src/lib/assetUtils.ts Outdated Show resolved Hide resolved
src/views/forms/AccountManagementForms/DepositForm.tsx Outdated Show resolved Hide resolved
@yogurtandjam yogurtandjam force-pushed the jerms/OTE-853_usetransfers-hook branch from 3271240 to 2202ef9 Compare October 18, 2024 15:58
if (isTokenCctp(fromToken)) {
// CCTP Deposits
return skipClient.msgsDirect({
...(baseParams as MsgsDirectRequest),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[fix] this doesn't need to be here

queryFn: async () => {
// this should never happen, this is just to satisfy typescript
// react queries should never return null.
if (!hasAllParams || !fromToken.decimals) return null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[fix] i should probably actually be throwing an error here

}),
skipClientId: crypto.randomUUID(),
Copy link
Contributor

Choose a reason for hiding this comment

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

👀 what is this clientId supposed to represent? can you leave a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooo good point! will do :)

allowUnsafe: true,
slippageTolerancePercent: '1',
smartRelay: true,
// TODO [onboarding-rewrite]: talk to skip about this, why are decimals optional? when would that happen?
Copy link
Contributor

Choose a reason for hiding this comment

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

move TODO to line 170?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh actually good point, we actually know why this happens now i'll update this comment

src/App.tsx Outdated
queryKey: ['transferEligibleAssets', skipClientId],
queryFn: () => assetsQueryFn(skipClient),
});
}, [skipClient]);
Copy link
Contributor

Choose a reason for hiding this comment

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

wont hurt to also just add in skipClientId here to get rid of the lint warning

src/App.tsx Outdated
@@ -100,6 +104,17 @@ const Content = () => {
}
}, [dispatch]);

useEffect(() => {
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 move this to a separate hook, or its own React component called <PreloadedQueries /> or something?

@yogurtandjam yogurtandjam force-pushed the jerms/OTE-853_usetransfers-hook branch from e943b6e to aa5a089 Compare October 18, 2024 17:44
@yogurtandjam yogurtandjam enabled auto-merge (squash) October 18, 2024 17:50
@yogurtandjam yogurtandjam merged commit 6322d60 into main Oct 18, 2024
8 checks passed
@yogurtandjam yogurtandjam deleted the jerms/OTE-853_usetransfers-hook branch October 18, 2024 17:51
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.

2 participants