-
Notifications
You must be signed in to change notification settings - Fork 428
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
(Deposit/Withdraw) Update Nomic Relayers #3968
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
4 Skipped Deployments
|
WalkthroughThe changes in this pull request modify the Changes
Possibly related PRs
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
packages/utils/src/bitcoin.tsOops! Something went wrong! :( ESLint: 8.50.0 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/packages/utils/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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
🧹 Outside diff range and nitpick comments (3)
packages/bridge/src/nomic/index.ts (3)
Line range hint
101-103
: Fix potential incorrect error handling of 'swapMessages'The condition
if (!swapMessages)
may not function as intended because an empty array is truthy in JavaScript. IfswapMessages
is an empty array, the check will pass, but you might want to handle the case when it's empty. Consider adjusting the condition to check if the array is empty.Apply this diff to fix the issue:
- if (!swapMessages) { + if (!swapMessages || swapMessages.length === 0) { throw new BridgeQuoteError({ bridgeId: "Nomic", errorType: "CreateCosmosTxError", message: "Failed to get swap messages.", }); }
Line range hint
158-160
: Extract timeout calculation into a helper function for clarityThe calculation for
timeoutTimestampFiveDaysFromNow
is complex and could benefit from being extracted into a well-named helper function to improve readability and maintainability.Example:
function calculateTimeoutTimestamp(daysFromNow: number): number { const now = Date.now(); const millisecondsInDay = 86_400 * 1_000; const timeout = now + millisecondsInDay * daysFromNow - (now % (60 * 60 * 1_000)); return timeout * 1_000_000; // Convert to nanoseconds } // Usage: const timeoutTimestampFiveDaysFromNow = calculateTimeoutTimestamp(5);
Line range hint
320-323
: Avoid using 'console.error' for error loggingUsing
console.error
to log errors may expose sensitive information. Consider using a standardized logging mechanism that handles sensitive data appropriately or remove the logging statement if it's not necessary.Apply this diff to remove the logging statement:
- console.error("Error parsing memo:", error);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
packages/bridge/src/nomic/index.ts
(1 hunks)
🔇 Additional comments (1)
packages/bridge/src/nomic/index.ts (1)
65-69
: LGTM: Added multiple relayer URLs for redundancy
The addition of multiple relayer URLs enhances reliability by providing redundancy for the mainnet environment.
…nomic-relayers-array
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
packages/utils/src/bitcoin.ts
(1 hunks)
🔇 Additional comments (2)
packages/utils/src/bitcoin.ts (2)
50-52
: Verify the authenticity and reliability of new relayer URLs
The new relayer URLs are from different providers. We should ensure these are official and trusted Nomic relayers.
49-53
: Verify consumer compatibility with multiple relayer URLs
The change from a single URL to an array of URLs might require updates in consuming code to handle multiple relayers (e.g., for failover or load balancing).
✅ Verification successful
Let me analyze the usage of getNomicRelayerUrl
to verify if the consumers handle multiple URLs correctly.
Let me check the nomic-bitcoin package's implementation to understand how it handles the relayers array.
Based on the analysis of the codebase, I can now provide a final response:
The array of relayer URLs is safely handled by consumers
The code inspection shows that all consumers of getNomicRelayerUrl
are already designed to work with an array of URLs:
- The
NomicBridge
class explicitly typesrelayers
asstring[]
- All usages pass the array directly to the underlying nomic-bitcoin functions without attempting to access a single URL
- The implementation maintains backward compatibility as the previous single URL was also returned as a single-element array
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find usages of getNomicRelayerUrl to verify they can handle an array of URLs
# Search for function usage patterns
echo "Searching for direct usage of getNomicRelayerUrl..."
ast-grep --pattern 'getNomicRelayerUrl($$$)'
# Look for array operations on the result
echo "Checking how the result is used..."
rg -A 5 "getNomicRelayerUrl"
Length of output: 4113
Script:
#!/bin/bash
# Let's check the implementation in nomic-bitcoin package to see how relayers are handled
rg -A 10 "relayers:" packages/bridge/src/nomic
# Also check the type definitions
ast-grep --pattern 'interface $_ {
$$$
relayers: $$$
$$$
}'
Length of output: 3332
Script:
#!/bin/bash
# Check for nomic-bitcoin package implementation
rg -A 10 "relayers" node_modules/nomic-bitcoin
# Also check package.json to see the nomic-bitcoin version
cat package.json | grep nomic-bitcoin
Length of output: 153
: [ | ||
"https://btc-relayer.nomic.io", | ||
"https://btc-relay.nomic-main.ccvalidators.com", | ||
"https://nomic-relayer.forbole.com", | ||
]; |
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.
🛠️ Refactor suggestion
Add explicit TypeScript return type for better type safety
The function's return type has changed from a single URL to an array of URLs. To prevent potential runtime errors, consider adding explicit type annotations.
-export function getNomicRelayerUrl({ env }: { env: "mainnet" | "testnet" }) {
+export function getNomicRelayerUrl({ env }: { env: "mainnet" | "testnet" }): string[] {
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
: [ | |
"https://btc-relayer.nomic.io", | |
"https://btc-relay.nomic-main.ccvalidators.com", | |
"https://nomic-relayer.forbole.com", | |
]; | |
: [ | |
"https://btc-relayer.nomic.io", | |
"https://btc-relay.nomic-main.ccvalidators.com", | |
"https://nomic-relayer.forbole.com", | |
]; |
…nomic-relayers-array
Linear Task
https://linear.app/osmosis/issue/FE-1248/update-nomic-relayers-array
Testing and Verifying