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: Adds new tx contract data model [REFACTOR] #102

Draft
wants to merge 2 commits into
base: abhk/hex
Choose a base branch
from

Conversation

moraesjeremias
Copy link
Member

@moraesjeremias moraesjeremias commented Feb 26, 2025

WIP DON'T MERGE

Will later adjust frontend layer.
Will do some local tests over the week.

Changes

  • Adds new tx contract data model
  • Moves tx request from bridge indexer to bridge api

Reason for change

  • New Bridge Indexer is now deployed on Hex and old one will soon be sunset in all networks.
  • We gotta adjust frontend layer to support new API contracts for transaction endpoint.

Copy link

vercel bot commented Feb 26, 2025

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

Name Status Preview Comments Updated (UTC)
bridge-ui ❌ Failed (Inspect) Feb 26, 2025 2:08am

@moraesjeremias moraesjeremias marked this pull request as draft February 26, 2025 02:07
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR refactors the transaction handling system to support the new Hex bridge API, replacing the soon-to-be-sunset bridge indexer across all networks.

  • Removed bridgeIndexerBaseUrl from config and updated bridgeApiBaseUrl to point to the new production sandbox URL
  • Added new TransactionResponseType enum in types/common.ts with AVAIL_SEND and ETH_SEND values
  • Significantly restructured the Transaction interface by removing chain-specific fields and consolidating token address fields into a single tokenId
  • Critical issue in validateParams function in services/transactions.ts where it returns an empty array in error cases instead of properly handling errors

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

4 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +27 to +33
function validateTransactionResponseType(queryParam: string) : string {
const chainAddressResponseMapping: Record<string, TransactionResponseType> = Object.freeze({
"ethAddress": TransactionResponseType.ETH_SEND,
"availAddress": TransactionResponseType.AVAIL_SEND
})
return chainAddressResponseMapping[queryParam];
}
Copy link

Choose a reason for hiding this comment

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

style: This function doesn't handle the case where queryParam is not one of the keys in chainAddressResponseMapping, which could lead to undefined being returned.

Suggested change
function validateTransactionResponseType(queryParam: string) : string {
const chainAddressResponseMapping: Record<string, TransactionResponseType> = Object.freeze({
"ethAddress": TransactionResponseType.ETH_SEND,
"availAddress": TransactionResponseType.AVAIL_SEND
})
return chainAddressResponseMapping[queryParam];
}
function validateTransactionResponseType(queryParam: string) : TransactionResponseType {
const chainAddressResponseMapping: Record<string, TransactionResponseType> = Object.freeze({
"ethAddress": TransactionResponseType.ETH_SEND,
"availAddress": TransactionResponseType.AVAIL_SEND
})
const type = chainAddressResponseMapping[queryParam];
if (!type) {
throw new Error(`Invalid query parameter: ${queryParam}`);
}
return type;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact early return/throws validation is way better.

e.g:

#L28 if !["",""].includes(queryParams) throw new Error(`Invalid query parameter: ${queryParam}`)

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.

1 participant