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

chore: update Base & Polygon ERC-20 custody addresses #430

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

fadeev
Copy link
Member

@fadeev fadeev commented Nov 22, 2024

Updating ERC-20 custody addresses following the migration.

Summary by CodeRabbit

  • New Features
    • Expanded support for additional symbols with the inclusion of "sBTC".
    • Enhanced blockchain name options by adding "empty" to the list.

Copy link
Contributor

coderabbitai bot commented Nov 22, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve updates to two exported type declarations in the v2/lib/types.ts file. The ParamSymbol type has been expanded to include the value "sBTC", and the ParamChainName type has been updated to add the value "empty". These modifications enhance the types by allowing for a broader range of symbols and blockchain names within the codebase.

Changes

File Change Summary
v2/lib/types.ts - Updated ParamSymbol to include "sBTC"
- Updated ParamChainName to include "empty"

Possibly related PRs

Suggested reviewers

  • lumtis
  • CharlieMc0
  • andresaiello
  • brewmaster012
  • fbac

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

We might want to precise Base, Polygon in PR title since BSC and Ethereum will follow unless you plan for those to include in this same PR

@lumtis
Copy link
Member

lumtis commented Nov 22, 2024

@fadeev I think you need to upgrade Foundry with foundryup to have the correct file generation

@fadeev fadeev changed the title chore: update erc20 custody addresses chore: update Base & Polygon ERC-20 custody addresses Nov 22, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.06%. Comparing base (03ce9e0) to head (74e19ba).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #430   +/-   ##
=======================================
  Coverage   84.06%   84.06%           
=======================================
  Files           8        8           
  Lines         389      389           
  Branches      124      124           
=======================================
  Hits          327      327           
  Misses         62       62           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fadeev
Copy link
Member Author

fadeev commented Nov 22, 2024

@fadeev I think you need to upgrade Foundry with foundryup to have the correct file generation

Done!

@lumtis
Copy link
Member

lumtis commented Nov 26, 2024

@fadeev maybe let's update Ethereum and BSC in this same PR at this point? Let's get it merged today

@fadeev
Copy link
Member Author

fadeev commented Nov 26, 2024

@fadeev maybe let's update Ethereum and BSC in this same PR at this point? Let's get it merged today

Done: 74e19ba

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 03ce9e0 and 74e19ba.

⛔ Files ignored due to path filters (2)
  • v2/data/addresses.mainnet.json is excluded by !v2/data/**
  • v2/data/addresses.testnet.json is excluded by !v2/data/**
📒 Files selected for processing (1)
  • v2/lib/types.ts (1 hunks)
🔇 Additional comments (1)
v2/lib/types.ts (1)

1-2: Verify corresponding updates in configuration files

Since these type changes are part of custody address updates, ensure that any related configuration files (e.g., network configs, deployment scripts) are updated to handle the new "sBTC" symbol and "empty" chain name.

✅ Verification successful

Type changes are properly aligned with configuration

The new symbols "sBTC" and chain name "empty" are correctly reflected in the testnet configuration file (v2/data/addresses.testnet.json):

  • "sBTC" is defined as a ZRC20 token with corresponding configuration
  • "empty" chain name is used for chain_id 18333 with TSS configuration

The changes are consistent with the custody address updates and properly configured in the system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for related configuration files that might need updates

# Search for configuration files with network/chain definitions
echo "Searching for network configuration files:"
fd -e json -e yaml -e toml | xargs rg -l "chain|network|custody"

# Search for deployment scripts
echo -e "\nSearching for deployment scripts:"
fd -e ts -e js | xargs rg -l "deploy.*custody"

Length of output: 5452


Script:

#!/bin/bash
# Let's check the content of address configuration files for any references to the new symbols
echo "Checking mainnet addresses configuration:"
cat v2/data/addresses.mainnet.json

echo -e "\nChecking testnet addresses configuration:"
cat v2/data/addresses.testnet.json

# Let's also check if these new types are already being used in the codebase
echo -e "\nChecking usage of new symbols:"
rg "sBTC|empty" --type ts

Length of output: 21717

@@ -1,4 +1,4 @@
export type ParamSymbol = "USDC.BSC" | "USDC.ETH" | "BTC.BTC" | "ETH.BASE" | "PEPE.ETH" | "BNB.BSC" | "SHIB.ETH" | "USDT.ETH" | "USDT.BSC" | "USDC.BASE" | "POL.POLYGON" | "DAI.ETH" | "ULTI.BSC" | "ETH.ETH" | "USDT.POL" | "ULTI.ETH" | "USDC.POL" | "sETH.SEPOLIA" | "ETH.BASESEPOLIA" | "tBTC" | "MATIC.AMOY" | "USDC" | "SOL.SOLANA" | "USDC.SEPOLIA" | "tBNB";
export type ParamChainName = "eth_mainnet" | "bsc_mainnet" | "polygon_mainnet" | "zeta_mainnet" | "btc_mainnet" | "base_mainnet" | "bsc_testnet" | "solana_devnet" | "zeta_testnet" | "btc_testnet" | "amoy_testnet" | "base_sepolia" | "sepolia_testnet";
export type ParamSymbol = "USDC.BSC" | "USDC.ETH" | "BTC.BTC" | "ETH.BASE" | "PEPE.ETH" | "BNB.BSC" | "SHIB.ETH" | "USDT.ETH" | "USDT.BSC" | "USDC.BASE" | "POL.POLYGON" | "DAI.ETH" | "ULTI.BSC" | "ETH.ETH" | "USDT.POL" | "ULTI.ETH" | "USDC.POL" | "sETH.SEPOLIA" | "ETH.BASESEPOLIA" | "tBTC" | "MATIC.AMOY" | "USDC" | "SOL.SOLANA" | "USDC.SEPOLIA" | "tBNB" | "sBTC";
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Add network suffix to "sBTC" for consistency

The codebase follows a consistent pattern where test tokens (prefixed with 's' or 't') include their network suffix (e.g., "sETH.SEPOLIA"). The newly added "sBTC" lacks this network designation, breaking this established pattern. This inconsistency could lead to confusion or potential issues in network-specific handling.

  • Consider updating "sBTC" to include its network, e.g., "sBTC.SEPOLIA" if it's meant for the Sepolia network
  • Other test tokens in the codebase: "sETH.SEPOLIA", "tBTC", "tBNB", "tMATIC" all maintain consistent naming
🔗 Analysis chain

Verify the naming pattern for "sBTC"

The newly added "sBTC" symbol deviates from the established pattern where tokens include their network (e.g., "USDC.BSC", "sETH.SEPOLIA"). While this might be intentional, we should verify its usage.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how "sBTC" is used in the codebase and verify if this naming is consistent

# Search for any references to sBTC in the codebase
echo "Searching for sBTC usage:"
rg "sBTC" --type ts

# Search for similar test token patterns to compare
echo -e "\nSearching for similar test token patterns:"
rg "s[A-Z]+\.[A-Z]+" --type ts

Length of output: 1628

@@ -3,2 +1,4 @@
export type ParamSymbol = "USDC.BSC" | "USDC.ETH" | "BTC.BTC" | "ETH.BASE" | "PEPE.ETH" | "BNB.BSC" | "SHIB.ETH" | "USDT.ETH" | "USDT.BSC" | "USDC.BASE" | "POL.POLYGON" | "DAI.ETH" | "ULTI.BSC" | "ETH.ETH" | "USDT.POL" | "ULTI.ETH" | "USDC.POL" | "sETH.SEPOLIA" | "ETH.BASESEPOLIA" | "tBTC" | "MATIC.AMOY" | "USDC" | "SOL.SOLANA" | "USDC.SEPOLIA" | "tBNB" | "sBTC";
export type ParamChainName = "eth_mainnet" | "bsc_mainnet" | "polygon_mainnet" | "zeta_mainnet" | "btc_mainnet" | "base_mainnet" | "bsc_testnet" | "solana_devnet" | "zeta_testnet" | "btc_testnet" | "empty" | "amoy_testnet" | "base_sepolia" | "sepolia_testnet";
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the implementation of getAddress and its usage, I can now provide a final response:

The "empty" chain type could lead to runtime errors

The getAddress function directly uses the network parameter to query addresses from a network list by matching chain_name. Using "empty" as a chain name will always result in undefined address since there's no corresponding network configuration with chain_name === "empty". This could lead to runtime errors when the function is called.

  • The getAddress implementation in v2/lib/addresses.ts uses chain_name === network for lookups
  • No special handling exists for the "empty" case
  • This will cause address to be undefined, leading to potential runtime errors

Consider these alternatives:

  1. Use undefined | null for uninitialized states instead of "empty"
  2. Add proper handling in getAddress if "empty" is a valid special case
  3. Use a discriminated union if this represents a distinct state: type ParamChainName = NetworkChain | { type: "uninitialized" }
🔗 Analysis chain

Consider a more type-safe alternative to "empty"

The addition of "empty" to ParamChainName deviates from the established network naming pattern and might introduce potential type-safety issues. Consider these alternatives:

  1. Use a separate type union with undefined/null if this represents an uninitialized state
  2. Create a discriminated union if this represents a special case

Example:

type NetworkChainName = "eth_mainnet" | "bsc_mainnet" | /* ... */;
type ParamChainName = NetworkChainName | { type: "empty" };

Let me gather more context about how this type is used in the codebase.


Let me search for the actual usage of this type in function calls to understand how "empty" is being used.


Let me check one more thing - looking at how this type is used in the codebase, particularly in the getAddress function implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how "empty" chain name is used to understand its purpose

# Search for usage of empty chain name
echo "Searching for empty chain usage:"
rg '"empty"' --type ts -C 3

# Look for similar patterns that might indicate uninitialized states
echo -e "\nSearching for similar initialization patterns:"
ast-grep --pattern 'type $_ = $_ | "empty" | $_'

Length of output: 1198


Script:

#!/bin/bash
# Search for ParamChainName usage to understand the context
echo "Searching for ParamChainName usage:"
rg "ParamChainName" --type ts -C 4

# Search for any function or variable that handles chain initialization
echo -e "\nSearching for chain initialization patterns:"
rg "chain.*(?:init|empty)" --type ts -C 4

Length of output: 5068


Script:

#!/bin/bash
# Search for getAddress function calls to see how the network parameter is used
echo "Searching for getAddress function calls:"
ast-grep --pattern 'getAddress($_, $network, $_)'

# Search for any string literals containing "empty" in typescript files
echo -e "\nSearching for 'empty' string literals in ts files:"
rg '"empty"' --type ts -A 2 -B 2

# Look for test files that might explain the usage
echo -e "\nSearching for test files containing 'empty':"
fd -e test.ts -e spec.ts -x rg -l "empty" {}

Length of output: 1392


Script:

#!/bin/bash
# Look at the implementation of getAddress to see how it handles the network parameter
echo "Searching for getAddress implementation:"
rg -A 15 "export const getAddress = \(.*\)" --type ts

# Check if there are any other files that might use "empty" chain
echo -e "\nSearching for files importing ParamChainName:"
rg "import.*ParamChainName" --type ts

Length of output: 3542

@lumtis lumtis merged commit 5368eb8 into main Nov 26, 2024
11 checks passed
@lumtis lumtis deleted the update-erc20custody-addresses branch November 26, 2024 15:50
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.

5 participants