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

Fix #78: Decode warp route messages. #144

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spilehchiha
Copy link

@spilehchiha spilehchiha commented Nov 27, 2024

This commit is a good base case for fixing #78.

Three edge cases remain to improve the UX:

  1. In the case of transferring ERC-721 tokens
  2. In the case of no value transfer transactions
  3. Correctly showing the token symbol on the UX

Will work on this.

Copy link

vercel bot commented Nov 27, 2024

@spilehchiha is attempting to deploy a commit to the Abacus Works Team on Vercel.

A member of the Team first needs to authorize it.

@spilehchiha spilehchiha mentioned this pull request Nov 27, 2024
1 task
Copy link
Collaborator

@jmrossy jmrossy left a comment

Choose a reason for hiding this comment

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

The general approach looks okay but needs some fixes please

@@ -105,6 +106,39 @@ export function ContentDetailsCard({
blurValue={blur}
/>
</div>
{warpRouteDetails && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please put this in its own card like the Interchain Gas Payments card

@@ -151,6 +159,7 @@ function parseMessage(
totalGasAmount: m.total_gas_amount.toString(),
totalPayment: m.total_payment.toString(),
numPayments: m.num_payments,
warpRouteDetails: warpRouteDetails ?? undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this ?? undefined doesn't do anything right?

import { postgresByteaToAddress } from '../features/messages/queries/encoding';
import { WarpRouteDetails } from '../types';

export function parseWarpRouteDetails(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move this to src/features/messages/queries/parse.ts as that's the only place it's used.
I'm not a big fan of accumulating business logic in the utils folders

metadata?: any
): WarpRouteDetails | undefined {
try {
if (!messageBody?.trim()) throw new Error('Invalid message body');
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not necessarily an invalid body. Just return undefined

totalPayment: utils.formatEther(gasInfo.totalPayment.toString())
};
} catch (error) {
console.error('Failed to parse token details:', error, 'Message body:', messageBody);
Copy link
Collaborator

Choose a reason for hiding this comment

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

no console, use logger. Did the lint not raise this?

Comment on lines +19 to +20
amount: utils.formatEther(parsedMessage.amount.toString()),
totalPayment: utils.formatEther(gasInfo.totalPayment.toString())
Copy link
Collaborator

Choose a reason for hiding this comment

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

const parsedMessage = parseWarpRouteMessage(messageBody);

return {
token: originTx?.to ? postgresByteaToAddress(originTx.to, metadata) : 'Unknown Token',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a huge deal but reorder things in the calling function so we don't have to decode this to value twice

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