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

Refactor solve form #26

Merged
merged 13 commits into from
Aug 21, 2023
Merged

Refactor solve form #26

merged 13 commits into from
Aug 21, 2023

Conversation

thal0x
Copy link
Member

@thal0x thal0x commented Aug 1, 2023

Refactors form logic to remove a lot of left over tech debt from the previous non-unified API.

🎉 Also adds tests 🎉

@vercel
Copy link

vercel bot commented Aug 1, 2023

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

Name Status Preview Comments Updated (UTC)
ibc-dot-fun ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 21, 2023 8:46pm

@thal0x thal0x marked this pull request as ready for review August 1, 2023 23:38
@thal0x thal0x requested a review from bpiv400 August 1, 2023 23:38
useEffect(() => {
if (!formValues.sourceChain && chains.length > 0) {
const chainID =
localStorage.getItem("IBC_DOT_FUN__LAST_SOURCE_CHAIN") ?? "cosmoshub-4";
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably define these const names in a consts file or at the top of this file and just refer to them here, rather than needing to refer to the raw text multiple times

useEffect(() => {
if (formValues.sourceChain) {
localStorage.setItem(
"IBC_DOT_FUN__LAST_SOURCE_CHAIN",
Copy link
Contributor

Choose a reason for hiding this comment

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

use variable name again

sourceAsset: feeAsset,
}));
} else {
const assets = assetsByChainID(formValues.sourceChain.chain_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be modified to make sure it only returns native assets -- and ideally only assets that include metadata.

For the first part, you can use the native_only field in the /assets request. For the second part, we need to implement all_assets first and only getting tokens with metadat will be the default behavior: https://linear.app/skip/issue/ENG-1582/add-all-assets-parameter-to-assets

Copy link
Member Author

Choose a reason for hiding this comment

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

This is already handled elsewhere

Copy link
Member Author

Choose a reason for hiding this comment

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

destinationAsset: feeAsset,
}));
} else {
const assets = assetsByChainID(formValues.destinationChain.chain_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment I made for source assets. Also feels like this logic could be abstracted to a helper function since it's duplicated

{!route.does_swap &&
`Successfully transfered ${
sourceAsset?.symbol ?? route.source_asset_denom
} from ${sourceChain.prettyName} to ${destinationChain.prettyName}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Where are you getting pretty name from? LMK if this is coming from somewhere outside of the API

Copy link
Member

Choose a reason for hiding this comment

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

Looks like it comes from chain-registry, our chains endpoint has a chain-name but it's not capitalized.

I assume he is using it this way because the chain registry one is easy to access.


const msgsResponse = await skipClient.fungible.getMessages(msgRequest);

// check balances on chains where a tx is initiated
Copy link
Contributor

Choose a reason for hiding this comment

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

good helper function opportunity

}

for (let i = 0; i < msgsResponse.msgs.length; i++) {
const multiHopMsg = msgsResponse.msgs[i];
Copy link
Contributor

Choose a reason for hiding this comment

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

Also good helper opportunity

],
{
amount: [coin(0, feeInfo.denom)],
gas: `${simulatedGas * 1.2}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this number to a well named constant var

}

if (multiHopMsg.chain_id === "evmos_9001-2") {
const tx = await signAndBroadcastEvmos(walletClient, msgJSON.sender, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do these have custom logic? Do we need to highlight this to users in our docs?


export async function getNumberOfTransactionsFromRoute(route: RouteResponse) {
const userAddresses: Record<string, string> = {};
for (const chainID of route.chain_ids) {
Copy link
Contributor

Choose a reason for hiding this comment

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

im sorry for causing this

@zrbecker zrbecker self-requested a review August 2, 2023 17:45
@zrbecker
Copy link
Member

zrbecker commented Aug 2, 2023

Added a few comments, agree with Barry's comments.

Copy link
Member

@zrbecker zrbecker left a comment

Choose a reason for hiding this comment

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

Let me know if you need another review on this before merge.

@thal0x thal0x merged commit e570722 into staging Aug 21, 2023
2 checks passed
@grikomsn grikomsn deleted the refactor-solve-form branch September 19, 2023 19:05
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.

3 participants