-
Notifications
You must be signed in to change notification settings - Fork 72
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: paymaster feature #841
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe updates primarily introduce a custom React hook, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant FreeRegisterCheckout
participant usePaymaster
participant Gasless SDK
participant Starknet
User->>FreeRegisterCheckout: Initiates Registration
FreeRegisterCheckout->>usePaymaster: Check Eligibility for Gasless Transaction
usePaymaster->>Starknet: Check Wallet Compatibility
Starknet-->>usePaymaster: Wallet Compatible
usePaymaster->>Gasless SDK: Retrieve Gas Token Pricing
Gasless SDK-->>usePaymaster: Gas Token Pricing
usePaymaster-->>FreeRegisterCheckout: Eligible for Gasless Transaction
FreeRegisterCheckout->>usePaymaster: Execute Transaction
usePaymaster->>Starknet: Execute Transaction on Starknet
Starknet-->>usePaymaster: Transaction Successful
usePaymaster-->>FreeRegisterCheckout: Transaction Result
FreeRegisterCheckout-->>User: Registration Completed
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- components/discount/freeRegisterCheckout.tsx (7 hunks)
- components/discount/freeRegisterSummary.tsx (2 hunks)
- package.json (3 hunks)
- tests/utils/stringService.test.js (2 hunks)
- utils/callData/registrationCalls.ts (3 hunks)
- utils/stringService.ts (1 hunks)
Additional comments not posted (12)
package.json (3)
14-14
: Updated@avnu/gasless-sdk
dependency.The update to version
^0.1.2
aligns with the PR's objective to implement the paymaster feature, which likely uses this SDK for gasless transactions. It's crucial to verify that other parts of the project that use this SDK are compatible with this new version.#!/bin/bash # Description: Verify compatibility of the updated @avnu/gasless-sdk with other project parts. # Test: Search for usage of @avnu/gasless-sdk across the project. Expect: No compatibility issues reported. rg --type typescript "@avnu/gasless-sdk"
25-26
: Updated@starknet-react
dependencies.The updates to
@starknet-react/chains
and@starknet-react/core
to versions^0.1.7
and^2.8.2
respectively are likely necessary for the new features or improvements in the StarkNet integration. Ensure that these updates do not introduce breaking changes.#!/bin/bash # Description: Check for potential breaking changes introduced by updates to @starknet-react packages. # Test: Search for usage of @starknet-react across the project. Expect: No breaking changes reported. rg --type typescript "@starknet-react"
47-47
: Updatedstarknet
dependency.The update to
starknet
version^6.7.0
is crucial for ensuring compatibility with the latest StarkNet features or security patches. Confirm that the update does not conflict with existing StarkNet integrations.#!/bin/bash # Description: Verify the compatibility of the updated starknet package with existing integrations. # Test: Search for usage of the starknet package. Expect: No compatibility issues reported. rg --type typescript "starknet"components/discount/freeRegisterSummary.tsx (2)
4-13
: Introduced new imports and props.The introduction of
DoneIcon
andGasTokenPrice
from@avnu/gasless-sdk
along with new optional props for handling gasless transactions (gasless
,gasTokenPrices
,gasTokenPrice
,setGasTokenPrice
) aligns with the PR's objectives to handle gasless transactions more effectively. Ensure that these props are used correctly throughout the component.
40-66
: Conditional rendering based ongasless
prop.The conditional rendering logic added for displaying either the
DoneIcon
and paymaster reward link or gas token selection buttons based on thegasless
prop is a good implementation. However, ensure that theDoneIcon
component and thePaymaster
link are accessible and meet UX standards.utils/callData/registrationCalls.ts (2)
87-87
: Updatedmint
function to use hexadecimal string conversion.The change to use
numberToStringHex
for converting token IDs to hexadecimal strings in themint
function is appropriate for the context where hexadecimal representation might be required by the StarkNet contracts.
224-229
: UpdatedgetFreeRegistrationCalls
to use hexadecimal string conversion.The update to use
numberToStringHex
for all elements in thecalldata
ofgetFreeRegistrationCalls
ensures consistency in data formatting for StarkNet transactions. This is crucial for avoiding errors in blockchain transactions due to data format mismatches.utils/stringService.ts (1)
178-184
: AddednumberToStringHex
utility function.The introduction of the
numberToStringHex
function to convert numbers or strings to hexadecimal strings is essential for handling data formatting in StarkNet transactions. Ensure that this function is used consistently wherever hexadecimal conversion is required.components/discount/freeRegisterCheckout.tsx (3)
21-34
: Imported multiple entities from@avnu/gasless-sdk
.The imports from
@avnu/gasless-sdk
are crucial for implementing the paymaster feature, which includes fetching account compatibility, rewards, and executing gasless transactions. Ensure that these functions are integrated properly and tested thoroughly to handle edge cases.
57-60
: Configuration forGaslessOptions
.The configuration setup for
GaslessOptions
using environment variables to determine the base URL is a secure and flexible approach. It allows for easy adaptation to different environments (testnet or mainnet).
274-295
: Handle register function with gasless condition.The
handleRegister
function's implementation to handle registration with or without gasless features based on thegaslessEnabled
flag is well-thought-out. However, ensure that error handling is robust, especially for transactions that might fail.#!/bin/bash # Description: Verify robust error handling in the handleRegister function. # Test: Search for error handling patterns in the handleRegister function. Expect: Comprehensive error handling. rg --type typescript "handleRegister" "components/discount/freeRegisterCheckout.tsx"tests/utils/stringService.test.js (1)
271-289
: Comprehensive Test Coverage fornumberToStringHex
The tests for the
numberToStringHex
function are well-structured and cover a variety of cases including undefined input, zero, positive numbers, and negative numbers. This ensures that the function's behavior is thoroughly validated under different conditions. Good job on covering these essential cases!
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.
Actionable comments posted: 5
Outside diff range and nitpick comments (2)
context/StarknetIdJsProvider.tsx (1)
Line range hint
29-29
: Simplify the boolean expressionThe use of a ternary operator here is unnecessary since the environment variable comparison directly returns a boolean. Simplifying this will enhance code readability.
- return process.env.NEXT_PUBLIC_IS_TESTNET === "true" ? true : false; + return process.env.NEXT_PUBLIC_IS_TESTNET === "true";components/UI/navbar.tsx (1)
Line range hint
161-166
: Improve accessibility by adding keyboard event handlers.Many clickable elements in the navigation bar are only accessible via mouse events. This can be an accessibility issue for users who rely on keyboard navigation. Consider adding corresponding keyboard event handlers such as
onKeyUp
oronKeyDown
.- <div onClick={handleNav} className="lg:hidden"> + <div onClick={handleNav} onKeyUp={handleNav} className="lg:hidden">Also applies to: 196-202, 214-218, 222-228, 241-241, 275-278, 289-289, 294-294, 299-299, 304-304, 312-312, 317-317, 327-327
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
Files selected for processing (10)
- components/UI/navbar.tsx (4 hunks)
- components/discount/freeRegisterCheckout.tsx (7 hunks)
- components/identities/actions/clickable/clickablePersonhoodIcon.tsx (3 hunks)
- context/StarknetIdJsProvider.tsx (2 hunks)
- hooks/useBalances.tsx (1 hunks)
- hooks/useNeedAllowances.tsx (1 hunks)
- hooks/useNotificationManager.ts (1 hunks)
- tests/utils/stringService.test.js (2 hunks)
- utils/connectorWrapper.ts (2 hunks)
- utils/stringService.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- components/discount/freeRegisterCheckout.tsx
Additional context used
Biome
context/StarknetIdJsProvider.tsx
[error] 29-29: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression withcomponents/identities/actions/clickable/clickablePersonhoodIcon.tsx
[error] 97-97: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 158-161: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 185-185: Alternative text title element cannot be empty (lint/a11y/noSvgWithoutTitle)
For accessibility purposes, SVGs should have an alternative text, provided via title element. If the svg element has role="img", you should add the aria-label or aria-labelledby attribute.
[error] 184-184: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)
The default type of a button is submit, which causes the submission of a form when placed inside a
form
element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or resetutils/stringService.ts
[error] 27-29: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 39-41: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 53-55: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 63-65: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 152-160: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 154-160: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
[error] 156-160: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
[error] 158-160: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
[error] 161-163: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 245-247: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
components/UI/navbar.tsx
[error] 82-82: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 161-166: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 196-202: Provide a text alternative through the alt, aria-label or aria-labelledby attribute (lint/a11y/useAltText)
Meaningful alternative text on elements helps users relying on screen readers to understand content's purpose within a page.
[error] 214-218: Provide a text alternative through the alt, aria-label or aria-labelledby attribute (lint/a11y/useAltText)
Meaningful alternative text on elements helps users relying on screen readers to understand content's purpose within a page.
[error] 222-228: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 241-241: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 275-278: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 289-289: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 294-294: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 299-299: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 304-304: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 312-312: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 317-317: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
[error] 327-327: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
Additional comments not posted (15)
context/StarknetIdJsProvider.tsx (2)
7-8
: Updated imports and usage of utility functions for chain ID conversionThe code now imports
mainnet
andsepolia
from@starknet-react/chains
andbigintToStringHex
from the utility module, which are used to handle the chain ID conversion based on the network environment. This is crucial for ensuring that the application functions correctly across different Starknet networks.
41-45
: Ensure proper handling of chain IDsThe conversion of chain IDs to hexadecimal string format is handled correctly using the
bigintToStringHex
utility function. This ensures that the application can correctly interact with the appropriate Starknet network. However, ensure that the returned types are correctly handled in all downstream usages.hooks/useBalances.tsx (1)
18-18
: Updated block identifier for contract readsThe
blockIdentifier
has been updated frompending
toPENDING
, aligning with the correct enum usage from the Starknet library. This ensures that the contract reads are correctly queued at the current pending block state.hooks/useNotificationManager.ts (1)
30-38
: Enhanced transaction status handlingThe logic for handling transaction statuses has been updated to use the
isRejected()
andisReverted()
methods, which are likely more robust and descriptive compared to the previous string-based checks. This is crucial for accurately reflecting the state of transactions in the user interface.hooks/useNeedAllowances.tsx (1)
27-27
: Updated block identifier for contract readsThe
blockIdentifier
has been updated frompending
toPENDING
, aligning with the correct enum usage from the Starknet library. This ensures that the contract reads are correctly queued at the current pending block state.components/identities/actions/clickable/clickablePersonhoodIcon.tsx (3)
20-22
: Updated utility imports for string manipulationThe component now imports
bigintToStringHex
andminifyDomain
from the utility module, which are used for formatting and displaying domain names and chain IDs. This update is crucial for ensuring that the data is presented correctly to the user.
30-30
: Updated chain imports for network handlingThe component now imports
mainnet
andsepolia
from@starknet-react/chains
, which are used to handle network-specific logic. This ensures that the component functions correctly across different Starknet networks.
228-229
: Dynamic chain ID assignment based on networkThe
Personhood
component now receives a dynamically assigned chain ID based on the current network environment (testnet
ormainnet
). This is crucial for ensuring that the personhood verification process interacts with the correct Starknet network.utils/stringService.ts (1)
178-193
: Added functions for converting numbers and BigInts to hexadecimal stringsThe newly added functions
numberToStringHex
andbigintToStringHex
provide utility for converting numeric values to their hexadecimal string representation. These are crucial for handling data that needs to be displayed or processed in hexadecimal format, often used in blockchain-related applications.utils/connectorWrapper.ts (6)
Line range hint
6-13
: Good use of environment variables for dynamic configuration inWebWalletConnector
.The function
getConnectors
effectively uses environment variables to configure the URL for theWebWalletConnector
. This approach enhances the flexibility and adaptability of the application to different deployment environments.
Line range hint
21-29
: Clear and effective sorting logic insortConnectors
.The function
sortConnectors
cleanly separates connectors into available and not available based on theiravailable()
method. This is a straightforward and effective way to manage the state of various connectors.
Line range hint
31-36
: Efficient retrieval and fallback mechanism ingetConnectorIcon
.The function
getConnectorIcon
efficiently retrieves the icon for a given connector ID and includes a sensible fallback to return the ID if no corresponding wallet is found.
Line range hint
38-43
: Consistent and clear retrieval logic ingetConnectorName
.The function
getConnectorName
uses a consistent approach withgetConnectorIcon
, efficiently retrieving the name for a given connector ID and providing a sensible fallback to return the ID if no corresponding wallet is found.
Line range hint
45-60
: Robust discovery URL retrieval ingetConnectorDiscovery
.The function
getConnectorDiscovery
handles multiple cases effectively: it returns a default ecosystem website if no wallet data is found, and it provides browser-specific download links when available. The conditional logic used here is robust and caters well to different client-side environments.
Line range hint
62-76
: Proper use of local storage for state persistence ingetLastConnector
andgetLastConnected
.Both functions,
getLastConnector
andgetLastConnected
, effectively uselocalStorage
to retrieve the last used or connected connector IDs and then find the corresponding connector from a list. This is a typical and well-implemented pattern for persisting user preferences on the client side.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- components/discount/freeRegisterCheckout.tsx (7 hunks)
Files skipped from review as they are similar to previous changes (1)
- components/discount/freeRegisterCheckout.tsx
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.
Actionable comments posted: 1
Outside diff range and nitpick comments (2)
utils/altcoinService.ts (2)
Line range hint
154-154
: Use exponentiation operator for better readability.Replace
Math.pow
with the exponentiation operator**
to enhance code readability and maintain modern JavaScript practices.- const strkQuote = BigInt(Math.round(quoteData.currentPrice * Math.pow(10, quoteData.decimals))); + const strkQuote = BigInt(Math.round(quoteData.currentPrice * (10 ** quoteData.decimals))); - (strkBalance * strkQuote) / BigInt(Math.pow(10, quoteData.decimals)); + (strkBalance * strkQuote) / BigInt(10 ** quoteData.decimals);Also applies to: 157-157
Line range hint
78-84
: Remove unnecessary else clauses for cleaner code.The
else
clauses can be omitted for cleaner and more efficient code since the previous branches break early.- if (!quoteData) return CurrencyType.ETH; - else { + if (!quoteData) return CurrencyType.ETH; - if (strkConvertedBalance > priceBigInt && ethBalance < priceBigInt) { - return CurrencyType.STRK; - } - else if (ethBalance > priceBigInt && strkConvertedBalance < priceBigInt) { - return CurrencyType.ETH; - } + if (strkConvertedBalance > priceBigInt && ethBalance < priceBigInt) return CurrencyType.STRK; + if (ethBalance > priceBigInt && strkConvertedBalance < priceBigInt) return CurrencyType.ETH;Also applies to: 94-99
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- components/discount/freeRegisterCheckout.tsx (8 hunks)
- components/discount/freeRegisterSummary.tsx (2 hunks)
- package.json (3 hunks)
- styles/components/registerV3.module.css (1 hunks)
- utils/altcoinService.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- styles/components/registerV3.module.css
Files skipped from review as they are similar to previous changes (2)
- components/discount/freeRegisterCheckout.tsx
- package.json
Additional context used
Biome
components/discount/freeRegisterSummary.tsx
[error] 47-51: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)
The default type of a button is submit, which causes the submission of a form when placed inside a
form
element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset
[error] 54-58: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)
The default type of a button is submit, which causes the submission of a form when placed inside a
form
element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset
[error] 95-102: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)
The default type of a button is submit, which causes the submission of a form when placed inside a
form
element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or resetutils/altcoinService.ts
[error] 78-84: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 94-99: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 154-154: Use the '**' operator instead of 'Math.pow'. (lint/style/useExponentiationOperator)
Unsafe fix: Use the '**' operator instead of 'Math.pow'.
[error] 157-157: Use the '**' operator instead of 'Math.pow'. (lint/style/useExponentiationOperator)
Unsafe fix: Use the '**' operator instead of 'Math.pow'.
Additional comments not posted (1)
components/discount/freeRegisterSummary.tsx (1)
12-17
: Add TypeScript types for new props.The props
hasPaymasterRewards
,gasTokenPrices
,gasTokenPrice
,setGasTokenPrice
, andsetGasMethod
are introduced without explicit TypeScript types. Adding types will improve type safety and developer experience.- hasPaymasterRewards?: boolean; - gasTokenPrices?: GasTokenPrice[]; - gasTokenPrice?: GasTokenPrice; - setGasTokenPrice: (price: GasTokenPrice) => void; - gasMethod: "traditional" | "paymaster"; - setGasMethod: (method: "traditional" | "paymaster") => void; + hasPaymasterRewards?: boolean; + gasTokenPrices?: GasTokenPrice[]; + gasTokenPrice?: GasTokenPrice; + setGasTokenPrice: (price: GasTokenPrice) => void; + gasMethod: "traditional" | "paymaster"; + setGasMethod: (method: "traditional" | "paymaster") => void;Likely invalid or redundant comment.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- hooks/paymaster.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- hooks/paymaster.tsx
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.
Actionable comments posted: 0
Outside diff range and nitpick comments (2)
utils/altcoinService.ts (2)
Line range hint
8-13
:
Improve error handling and logging.The function logs errors to the console. Consider using a more robust logging mechanism and handling non-200 HTTP responses.
export const getTokenQuote = async (tokenAddress: string) => { try { const res = await fetch( `${process.env.NEXT_PUBLIC_SERVER_LINK}/get_altcoin_quote?erc20_addr=${tokenAddress}` ); if (!res.ok) { throw new Error(`Server responded with status ${res.status}`); } return await res.json(); } catch (error) { console.error("Error querying quote from server: ", error); } };
Line range hint
36-51
:
Remove or uncomment the commented-out code.The commented-out code for USDC and USDT should be either removed or uncommented based on the requirements.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- utils/altcoinService.ts (1 hunks)
Additional comments not posted (6)
utils/altcoinService.ts (6)
Line range hint
15-24
:
LGTM!The function correctly calculates the domain price in an altcoin using precise arithmetic operations.
Line range hint
26-34
:
LGTM!The function correctly calculates the price for a given duration using precise arithmetic operations.
Line range hint
53-66
:
LGTM!The function correctly calculates the renewal price in ETH and handles both error and success cases appropriately.
Line range hint
68-78
:
LGTM!The function correctly calculates the domain price based on the currency type by delegating the calculation to appropriate helper functions.
Line range hint
80-92
:
LGTM!The function correctly calculates the auto-renew allowance based on the currency type, sales tax rate, and domain price using helper functions.
182-192
: LGTM!The
tokenNames
object correctly maps various token addresses to their corresponding names.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- hooks/paymaster.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- hooks/paymaster.tsx
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- hooks/paymaster.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- hooks/paymaster.tsx
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- hooks/paymaster.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- hooks/paymaster.tsx
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- components/discount/freeRegisterCheckout.tsx (7 hunks)
- hooks/paymaster.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- components/discount/freeRegisterCheckout.tsx
- hooks/paymaster.tsx
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- hooks/paymaster.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- hooks/paymaster.tsx
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.
lgtm
close: #826
To test, go to /gift
Summary by CodeRabbit
New Features
usePaymaster
custom React hook to manage gasless transactions, including account checks, gas token pricing, rewards, and transaction execution.tokenNames
function for mapping token addresses to their names.Updates
package.json
:@avnu/gasless-sdk
andqs
.@starknet-react/chains
,@starknet-react/core
, andget-starknet-core
.Enhancements
FreeRegisterCheckout
component to incorporateusePaymaster
, enhancing the handling of paymaster-related functionalities and gas token management.