-
Notifications
You must be signed in to change notification settings - Fork 83
Add isGuarded prop (#433) #434
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
Conversation
Summary of ChangesHello @arhtudormorar, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly introduces the isGuarded property to handle transactions for guarded accounts by increasing the gas limit. The implementation is straightforward and propagated through the necessary functions. I've left a few comments suggesting improvements regarding code clarity and maintainability, such as replacing a magic number with a constant, fixing a typo, and reducing some code repetition. Overall, good work!
| if (isGuarded) { | ||
| tokenTransfer.gasLimit = tokenTransfer.gasLimit + BigInt(50_000); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value 50_000 is a magic number. It would be better to define it as a named constant, for example GAS_LIMIT_ADDITIONAL_FOR_GUARDED_ACCOUNT, in a shared configuration file (e.g., src/config/index.ts). This improves readability and maintainability, as the value is used in multiple places (getSwapAndLockTransactions.ts, getWrapAndMultiTransferTransactions.ts).
For example:
// src/config/constants.ts
export const GAS_LIMIT_ADDITIONAL_FOR_GUARDED_ACCOUNT = 50_000;
// Then in this file:
import { GAS_LIMIT_ADDITIONAL_FOR_GUARDED_ACCOUNT } from 'config/constants';
// ...
if (isGuarded) {
tokenTransfer.gasLimit += BigInt(GAS_LIMIT_ADDITIONAL_FOR_GUARDED_ACCOUNT);
}| nonce | ||
| }: TransactionProps): Transaction[] => { | ||
| return [ | ||
| const transcations = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (isGuarded) { | ||
| wrapOneEgld.gasLimit = wrapOneEgld.gasLimit + BigInt(50_000); | ||
| swapHalfWEgldToUsdc.gasLimit = | ||
| swapHalfWEgldToUsdc.gasLimit + BigInt(50_000); | ||
| multiTransferOneUsdcHalfWEgld.gasLimit = | ||
| multiTransferOneUsdcHalfWEgld.gasLimit + BigInt(50_000); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code is repetitive. You could group the transactions into an array and iterate over them to add the extra gas limit, similar to how it's done in getSwapAndLockTransactions.ts. This would make the code more concise and easier to maintain if more transactions are added in the future.
Also, as mentioned in another comment, the magic number 50_000 should be replaced with a named constant.
| if (isGuarded) { | |
| wrapOneEgld.gasLimit = wrapOneEgld.gasLimit + BigInt(50_000); | |
| swapHalfWEgldToUsdc.gasLimit = | |
| swapHalfWEgldToUsdc.gasLimit + BigInt(50_000); | |
| multiTransferOneUsdcHalfWEgld.gasLimit = | |
| multiTransferOneUsdcHalfWEgld.gasLimit + BigInt(50_000); | |
| } | |
| if (isGuarded) { | |
| [wrapOneEgld, swapHalfWEgldToUsdc, multiTransferOneUsdcHalfWEgld].forEach( | |
| (tx) => { | |
| tx.gasLimit += BigInt(50_000); | |
| } | |
| ); | |
| } |
* Fix typo * Update
No description provided.