-
Notifications
You must be signed in to change notification settings - Fork 62
[CP-395] add support for v1.16 #308
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
…d examples for the new queries and messages.
WalkthroughThe update introduces new ERC20 and EVM query methods to the chain client, expands the mock client for testing these features, and adds multiple example programs demonstrating their usage. Dependency versions are upgraded in Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ChainClient
participant ERC20Module
participant EVMModule
User->>ChainClient: FetchAllTokenPairs()
ChainClient->>ERC20Module: QueryAllTokenPairs
ERC20Module-->>ChainClient: AllTokenPairsResponse
ChainClient-->>User: AllTokenPairsResponse
User->>ChainClient: FetchEVMAccount(address)
ChainClient->>EVMModule: QueryAccount(address)
EVMModule-->>ChainClient: AccountResponse
ChainClient-->>User: AccountResponse
Poem
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. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
Documentation and Community
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
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.
Pull Request Overview
This PR adds support for v1.16 by integrating new queries for the evm and erc20 modules along with corresponding example programs.
- Adds example programs for various evm queries (e.g., base fee, code, storage, accounts).
- Introduces example programs for erc20 queries (e.g., token pair by denom and by ERC20 address, all token pairs, create/delete token pair).
- Updates client packages to support the new query functions for ERC20 and evm modules.
Reviewed Changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/chain/evm/query/7_BaseFee/example.go | Adds an example for fetching the EVM base fee. |
| examples/chain/evm/query/6_Code/example.go | Adds an example for fetching EVM code. |
| examples/chain/evm/query/5_Storage/example.go | Adds an example for fetching EVM storage data. |
| examples/chain/evm/query/4_Balance/example.go | Adds an example for fetching an EVM account balance. |
| examples/chain/evm/query/3_ValidatorAccount/example.go | Adds an example for fetching EVM validator account details. |
| examples/chain/evm/query/2_CosmosAccount/example.go | Adds an example for fetching EVMCosmos account data. |
| examples/chain/evm/query/1_Account/example.go | Adds an example for fetching a general EVM account. |
| examples/chain/erc20/query/3_TokenPairByERC20Address/example.go | Adds an example for querying token pair by ERC20 address. |
| examples/chain/erc20/query/2_TokenPairByDenom/example.go | Adds an example for querying token pair by bank denom. |
| examples/chain/erc20/query/1_AllTokenPairs/example.go | Adds an example for querying all token pairs. |
| examples/chain/erc20/2_DeleteTokenPair/example.go | Adds an example for deleting an ERC20 token pair. |
| examples/chain/erc20/1_CreateTokenPair/example.go | Adds an example for creating an ERC20 token pair. |
| examples/chain/12_ChainStream/example.go | Updates the chain stream example to use the new v2 module imports. |
| client/chain/chain_test_support.go | Introduces new dummy functions for ERC20 and evm module queries in test support. |
| client/chain/chain.go | Integrates new query functions for ERC20 and evm modules into the chain client. |
Files not reviewed (2)
- Makefile: Language not supported
- go.mod: Language not supported
| fmt.Println(err) | ||
| } | ||
|
|
||
| str, _ := json.MarshalIndent(res, "", " ") |
Copilot
AI
May 27, 2025
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.
[nitpick] Consider handling the error from json.MarshalIndent instead of ignoring it to avoid silent failures.
| str, _ := json.MarshalIndent(res, "", " ") | |
| str, err := json.MarshalIndent(res, "", " ") | |
| if err != nil { | |
| fmt.Printf("Error marshaling JSON: %v\n", err) | |
| return | |
| } |
| gasPrice = chainClient.CurrentChainGasPrice() | ||
| // adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted | ||
| gasPrice = int64(float64(gasPrice) * 1.1) | ||
| chainClient.SetGasPrice(gasPrice) |
Copilot
AI
May 27, 2025
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.
[nitpick] Consider refactoring the repeated gas price adjustment logic into a helper function to reduce duplication and improve maintainability.
| gasPrice = chainClient.CurrentChainGasPrice() | |
| // adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted | |
| gasPrice = int64(float64(gasPrice) * 1.1) | |
| chainClient.SetGasPrice(gasPrice) | |
| adjustAndSetGasPrice(chainClient) |
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: 2
♻️ Duplicate comments (3)
examples/chain/evm/query/7_BaseFee/example.go (1)
66-66: Handle the error from json.MarshalIndent.Consider handling the error from json.MarshalIndent instead of ignoring it to avoid silent failures.
- str, _ := json.MarshalIndent(res, "", " ") + str, err := json.MarshalIndent(res, "", " ") + if err != nil { + fmt.Printf("Error marshaling JSON: %v\n", err) + return + }examples/chain/erc20/1_CreateTokenPair/example.go (1)
55-58: Refactor duplicated gas price adjustment logicThe gas price adjustment logic is duplicated in two places. Consider extracting this into a helper function to improve maintainability and reduce code duplication.
This matches a previous review comment about refactoring the repeated gas price adjustment logic.
Also applies to: 89-92
examples/chain/erc20/2_DeleteTokenPair/example.go (1)
55-58: Refactor duplicated gas price adjustment logicThe same gas price adjustment duplication issue exists here as in the CreateTokenPair example.
This matches the previous review comment about refactoring the repeated gas price adjustment logic into a helper function.
Also applies to: 85-88
🧹 Nitpick comments (12)
examples/chain/evm/query/7_BaseFee/example.go (1)
29-29: Consider using a placeholder or warning comment for the private key.The hard-coded private key in examples could pose a security risk if users copy this code without understanding the implications. Consider using a clearly marked placeholder or adding a warning comment.
- "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // WARNING: Replace with your own private key in productionexamples/chain/evm/query/5_Storage/example.go (2)
29-29: Consider using a placeholder or warning comment for the private key.The hard-coded private key in examples could pose a security risk if users copy this code without understanding the implications. Consider using a clearly marked placeholder or adding a warning comment.
- "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // WARNING: Replace with your own private key in production
68-68: Handle the error from json.MarshalIndent.Consider handling the error from json.MarshalIndent instead of ignoring it to avoid silent failures.
- str, _ := json.MarshalIndent(res, "", " ") + str, err := json.MarshalIndent(res, "", " ") + if err != nil { + fmt.Printf("Error marshaling JSON: %v\n", err) + return + }examples/chain/evm/query/1_Account/example.go (2)
67-68: Handle JSON marshaling error.The JSON marshaling error is currently ignored, which could lead to silent failures.
- str, _ := json.MarshalIndent(res, "", " ") - fmt.Print(string(str)) + str, err := json.MarshalIndent(res, "", " ") + if err != nil { + fmt.Printf("Error marshaling response: %v\n", err) + return + } + fmt.Print(string(str))
23-31: Consider documenting test credentials.The hardcoded private key and credentials are appropriate for examples, but consider adding a comment to clarify these are test credentials.
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( os.Getenv("HOME")+"/.injectived", "injectived", "file", "inj-user", "12345678", - "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // test private key for example - keyring will be used if pk not provided false, )examples/chain/erc20/query/2_TokenPairByDenom/example.go (1)
66-67: Handle JSON marshaling error.The JSON marshaling error is currently ignored, which could lead to silent failures.
- str, _ := json.MarshalIndent(res, "", " ") - fmt.Print(string(str)) + str, err := json.MarshalIndent(res, "", " ") + if err != nil { + fmt.Printf("Error marshaling response: %v\n", err) + return + } + fmt.Print(string(str))examples/chain/evm/query/4_Balance/example.go (1)
67-68: Handle JSON marshaling error.The JSON marshaling error is currently ignored, which could lead to silent failures.
- str, _ := json.MarshalIndent(res, "", " ") - fmt.Print(string(str)) + str, err := json.MarshalIndent(res, "", " ") + if err != nil { + fmt.Printf("Error marshaling response: %v\n", err) + return + } + fmt.Print(string(str))examples/chain/evm/query/6_Code/example.go (1)
67-68: Handle JSON marshaling error.The JSON marshaling error is currently ignored, which could lead to silent failures.
- str, _ := json.MarshalIndent(res, "", " ") - fmt.Print(string(str)) + str, err := json.MarshalIndent(res, "", " ") + if err != nil { + fmt.Printf("Error marshaling response: %v\n", err) + return + } + fmt.Print(string(str))examples/chain/erc20/1_CreateTokenPair/example.go (2)
22-30: Security concern: Hardcoded credentials and private keyThis example contains hardcoded sensitive information including keyring password and private key. While this is acceptable for example/demo purposes, it should be clearly documented as such to prevent accidental production usage.
Consider adding a comment to clarify this is for demo purposes only:
+ // NOTE: This example uses hardcoded credentials for demonstration purposes only. + // In production, use secure credential management practices. senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( os.Getenv("HOME")+"/.injectived", "injectived", "file", "inj-user", "12345678", "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided false, )
78-78: Consider more robust transaction confirmationUsing a fixed 5-second sleep is not ideal for production code as transaction confirmation times can vary. Consider implementing proper transaction status polling instead.
For production code, consider implementing transaction status polling:
- time.Sleep(time.Second * 5) + // Poll for transaction confirmation instead of fixed sleep + // Example: implement a retry mechanism with exponential backoffexamples/chain/erc20/2_DeleteTokenPair/example.go (2)
22-30: Security concern: Hardcoded credentials and private keySame security concern as in the CreateTokenPair example. This example also contains hardcoded sensitive information.
Consider adding the same security disclaimer comment as suggested for the CreateTokenPair example to maintain consistency across examples.
74-74: Consider more robust transaction confirmationSame fixed sleep issue as in the CreateTokenPair example.
Consider implementing the same transaction status polling approach suggested for the CreateTokenPair example.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
exchange/derivative_exchange_rpc/pb/goadesign_goagen_injective_derivative_exchange_rpc.pb.gois excluded by!**/*.pb.gogo.sumis excluded by!**/*.sum
📒 Files selected for processing (17)
Makefile(1 hunks)client/chain/chain.go(5 hunks)client/chain/chain_test_support.go(2 hunks)examples/chain/12_ChainStream/example.go(2 hunks)examples/chain/erc20/1_CreateTokenPair/example.go(1 hunks)examples/chain/erc20/2_DeleteTokenPair/example.go(1 hunks)examples/chain/erc20/query/1_AllTokenPairs/example.go(1 hunks)examples/chain/erc20/query/2_TokenPairByDenom/example.go(1 hunks)examples/chain/erc20/query/3_TokenPairByERC20Address/example.go(1 hunks)examples/chain/evm/query/1_Account/example.go(1 hunks)examples/chain/evm/query/2_CosmosAccount/example.go(1 hunks)examples/chain/evm/query/3_ValidatorAccount/example.go(1 hunks)examples/chain/evm/query/4_Balance/example.go(1 hunks)examples/chain/evm/query/5_Storage/example.go(1 hunks)examples/chain/evm/query/6_Code/example.go(1 hunks)examples/chain/evm/query/7_BaseFee/example.go(1 hunks)go.mod(6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
examples/chain/erc20/query/2_TokenPairByDenom/example.go (6)
client/common/network.go (1)
LoadNetwork(53-202)client/chain/keys.go (1)
InitCosmosKeyring(28-164)client/chain/context.go (1)
NewClientContext(129-215)client/chain/chain.go (1)
NewChainClient(531-654)client/common/options.go (1)
OptionGasPrices(36-47)client/constants.go (1)
DefaultGasPriceWithDenom(6-6)
examples/chain/erc20/query/3_TokenPairByERC20Address/example.go (6)
client/common/network.go (1)
LoadNetwork(53-202)client/chain/keys.go (1)
InitCosmosKeyring(28-164)client/chain/context.go (1)
NewClientContext(129-215)client/chain/chain.go (1)
NewChainClient(531-654)client/common/options.go (1)
OptionGasPrices(36-47)client/constants.go (1)
DefaultGasPriceWithDenom(6-6)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: lint
🔇 Additional comments (26)
Makefile (1)
4-4:Details
❓ Verification inconclusive
Verify the updated branch version exists.
The branch update from
v1.16.0-rc2tov1.16.3aligns with the PR's objective of adding v1.16 support. This change from a release candidate to a stable version is positive.Please verify that the
v1.16.3branch exists in the injective-indexer repository:
🏁 Script executed:
#!/bin/bash # Description: Verify that the v1.16.3 branch exists in the injective-indexer repository git ls-remote --heads https://github.com/InjectiveLabs/injective-indexer.git | grep "v1.16.3"Length of output: 209
🏁 Script executed:
#!/bin/bash # List all repositories in the InjectiveLabs organization and filter for names containing "indexer" curl -s https://api.github.com/orgs/InjectiveLabs/repos?per_page=200 \ | jq -r '.[] | select(.name | test("(?i)indexer")) | "\(.name) -> \(.clone_url)"'Length of output: 154
Confirm repository URL and branch existence.
The clone command for
https://github.com/InjectiveLabs/injective-indexer.gitreturns “repository not found.” Please verify:
- The correct GitHub repository path for the indexer.
- That a branch or tag named v1.16.3 exists in that repository.
examples/chain/12_ChainStream/example.go (2)
8-8: LGTM! Improved naming consistency.The alias change from
chainStreamModuletochainstreamv2improves clarity by explicitly indicating this is version 2 of the chain stream types.
42-78: LGTM! Consistent usage of the updated alias.All type references have been consistently updated to use the new
chainstreamv2alias, maintaining code coherency.examples/chain/evm/query/7_BaseFee/example.go (1)
61-64: LGTM! Proper usage of the new EVM base fee query.The example correctly demonstrates the usage of the new
FetchEVMBaseFeemethod with appropriate error handling.examples/chain/evm/query/5_Storage/example.go (1)
61-66: LGTM! Proper usage of the new EVM storage query.The example correctly demonstrates the usage of the new
FetchEVMStoragemethod with appropriate parameters and error handling.examples/chain/erc20/query/3_TokenPairByERC20Address/example.go (1)
16-60: Example setup and error handling look good.The initialization code follows the standard pattern for SDK examples with appropriate testnet configuration. The hardcoded credentials are acceptable for demonstration purposes.
Also applies to: 63-70
examples/chain/evm/query/2_CosmosAccount/example.go (1)
16-70: LGTM! Proper implementation of EVM Cosmos account query.The example correctly demonstrates the
FetchEVMCosmosAccountmethod with appropriate setup and error handling. The EVM address format and method call are consistent with the example's purpose.examples/chain/erc20/query/1_AllTokenPairs/example.go (1)
16-69: LGTM! Clean implementation of all token pairs query.The example properly demonstrates the
FetchAllTokenPairsmethod with standard setup code and appropriate error handling. The implementation aligns perfectly with the filename and intended functionality.examples/chain/evm/query/3_ValidatorAccount/example.go (1)
16-70: LGTM! Correct implementation of EVM validator account query.The example properly demonstrates the
FetchEVMValidatorAccountmethod using a valid consensus address format. The setup and error handling follow the established pattern for SDK examples.examples/chain/evm/query/4_Balance/example.go (1)
61-62: Good consistency with other examples.Using the same EVM address across related examples provides consistency and makes it easier to compare results across different query types.
examples/chain/evm/query/6_Code/example.go (1)
16-70: Well-structured example demonstrating EVM code query.The example follows consistent patterns with other EVM query examples and properly demonstrates the usage of the new
FetchEVMCodefunctionality. The client initialization, error handling, and output formatting are appropriate for an example program.examples/chain/erc20/1_CreateTokenPair/example.go (1)
60-68: LGTM: Token pair configurationThe token pair configuration with USDT denomination and ERC20 address is correctly structured and follows the expected pattern for the
MsgCreateTokenPairmessage.examples/chain/erc20/2_DeleteTokenPair/example.go (1)
62-65: LGTM: Delete token pair message structureThe
MsgDeleteTokenPairmessage is correctly constructed with the appropriate sender and bank denomination fields.go.mod (4)
14-14: LGTM: CosmWasm dependency updateThe upgrade to CosmWasm/wasmd v0.53.2 aligns with supporting the new EVM and ERC20 module features.
24-24: LGTM: IBC-go version updateThe update to cosmos/ibc-go/v8 v8.6.1 is appropriate for the new module support.
240-256: LGTM: Coordinated Injective cosmos-sdk updatesThe systematic update of all InjectiveLabs cosmos-sdk modules from
-inj.2to-inj.3indicates a coordinated upgrade to support the new EVM and ERC20 functionality.
273-273:Details
✅ Verification successful
New replace directive for go-bip39
A new replace directive has been added for
github.com/tyler-smith/go-bip39pointing to the InjectiveLabs fork. This suggests there may be custom modifications needed.Please verify that the InjectiveLabs fork of go-bip39 is necessary and properly maintained:
🏁 Script executed:
#!/bin/bash # Check if the InjectiveLabs go-bip39 fork exists and get its details curl -s https://api.github.com/repos/InjectiveLabs/go-bip39 | jq '{name, description, updated_at, default_branch}' # Check for any obvious differences in recent commits curl -s https://api.github.com/repos/InjectiveLabs/go-bip39/commits?per_page=5 | jq '.[].commit.message' curl -s https://api.github.com/repos/tyler-smith/go-bip39/commits?per_page=5 | jq '.[].commit.message'Length of output: 581
🏁 Script executed:
#!/bin/bash # Retrieve recent commit messages for the original tyler-smith go-bip39 curl -sL https://api.github.com/repos/tyler-smith/go-bip39/commits?per_page=5 | jq '.[].commit.message' # List tags of the original tyler-smith go-bip39 echo "tyler-smith/go-bip39 tags:" curl -s https://api.github.com/repos/tyler-smith/go-bip39/tags | jq '.[].name' # List tags of the InjectiveLabs go-bip39 fork echo "InjectiveLabs/go-bip39 tags:" curl -s https://api.github.com/repos/InjectiveLabs/go-bip39/tags | jq '.[].name'Length of output: 542
Confirmed: InjectiveLabs go-bip39 fork is required and maintained
The originaltyler-smith/go-bip39repo appears to be removed (GitHub API returns “Not Found”), while the InjectiveLabs fork:
- Is live (last updated 2025-05-21) on branch
main- Publishes a v1.1.0 tag matching the version in your replace directive
- Contains the recovery commit (“Recover the package (gh got nuked).”)
The replace directive is both necessary (original is deleted) and correctly points to an actively maintained fork.
client/chain/chain_test_support.go (3)
27-28: LGTM: Import statements for new modulesThe addition of import statements for ERC20 and EVM types is correctly placed and follows the existing import organization pattern.
1170-1182: LGTM: ERC20 module mock implementationsThe mock methods for ERC20 queries are well-structured and follow the established pattern of returning empty responses with nil errors. All three core ERC20 query methods are covered:
FetchAllTokenPairsFetchTokenPairByDenomFetchTokenPairByERC20Address
1183-1211: LGTM: EVM module mock implementationsThe mock methods for EVM queries comprehensively cover all the new EVM functionality:
- Account queries (
FetchEVMAccount,FetchEVMCosmosAccount,FetchEVMValidatorAccount)- Balance query (
FetchEVMBalance)- Storage and code queries (
FetchEVMStorage,FetchEVMCode)- Base fee query (
FetchEVMBaseFee)All methods follow the consistent mock pattern and provide the necessary test infrastructure.
client/chain/chain.go (6)
42-43: LGTM! Clean import additions for new module support.The imports for ERC20 and EVM types are properly added and follow the existing import structure conventions.
457-470: Excellent interface extension for ERC20 and EVM queries.The new method signatures are well-designed and consistent with the existing interface patterns:
- All methods follow the standard
(ctx context.Context, ...) (*Response, error)signature- Method names are descriptive and follow the
Fetchprefix convention- ERC20 methods cover comprehensive token pair queries (all pairs, by denom, by ERC20 address)
- EVM methods provide complete account and blockchain data access (accounts, balances, storage, code, base fee)
511-512: Proper addition of query clients to the struct.The new query client fields are appropriately named and positioned within the existing query client grouping in the struct definition.
617-618: Correct initialization of new query clients.The query clients are properly initialized using
NewQueryClient(conn)following the exact same pattern as all other query clients in the constructor.
3609-3635: Well-implemented ERC20 query methods.All three ERC20 query methods are correctly implemented:
FetchAllTokenPairs: Properly handles empty request for fetching all pairsFetchTokenPairByDenom: Correctly sets the BankDenom field from parameterFetchTokenPairByERC20Address: Properly sets the Erc20Address field from parameterEach method follows the established pattern of creating request, calling
common.ExecuteCall, and returning the response.
3636-3696: Comprehensive and well-structured EVM query implementations.All EVM query methods are excellently implemented with proper patterns:
- Account-related queries (
FetchEVMAccount,FetchEVMCosmosAccount,FetchEVMValidatorAccount) correctly handle address parametersFetchEVMBalanceproperly sets the address fieldFetchEVMStorageincludes appropriate conditional logic for the optional key parameterFetchEVMCodecorrectly handles address parameterFetchEVMBaseFeeproperly creates an empty request for base fee queriesThe conditional key handling in
FetchEVMStorage(lines 3675-3677) is particularly well done, using a pointer to handle the optional parameter appropriately.
| usdtERC20 := "0xdAC17F958D2ee523a2206206994597C13D831ec7" | ||
| res, err := chainClient.FetchTokenPairByDenom(ctx, usdtERC20) |
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.
Critical: Wrong method called for ERC20 address query.
The filename and variable name suggest this example should demonstrate querying by ERC20 address, but it's calling FetchTokenPairByDenom instead of FetchTokenPairByERC20Address. The variable contains an ERC20 address (0xdAC17F958D2ee523a2206206994597C13D831ec7), not a denomination.
Apply this fix:
- res, err := chainClient.FetchTokenPairByDenom(ctx, usdtERC20)
+ res, err := chainClient.FetchTokenPairByERC20Address(ctx, usdtERC20)📝 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.
| usdtERC20 := "0xdAC17F958D2ee523a2206206994597C13D831ec7" | |
| res, err := chainClient.FetchTokenPairByDenom(ctx, usdtERC20) | |
| usdtERC20 := "0xdAC17F958D2ee523a2206206994597C13D831ec7" | |
| - res, err := chainClient.FetchTokenPairByDenom(ctx, usdtERC20) | |
| + res, err := chainClient.FetchTokenPairByERC20Address(ctx, usdtERC20) |
🤖 Prompt for AI Agents
In examples/chain/erc20/query/3_TokenPairByERC20Address/example.go at lines
61-62, the code incorrectly calls FetchTokenPairByDenom with an ERC20 address
variable. Replace the method call with FetchTokenPairByERC20Address to correctly
query using the ERC20 address stored in usdtERC20.
|
|
||
| ctx := context.Background() | ||
|
|
||
| res, err := chainClient.FetchTokenPairByERC20Address(ctx, "usdt") |
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.
💡 Verification agent
🧩 Analysis chain
Verify method name and parameter consistency.
There appears to be a mismatch between the method name FetchTokenPairByERC20Address and the parameter "usdt". The method name suggests it expects an ERC20 address, but "usdt" appears to be a token symbol/denomination rather than an address.
Please verify if this should be:
FetchTokenPairByDenom(ctx, "usdt")- if querying by denominationFetchTokenPairByERC20Address(ctx, "0x...")- if querying by ERC20 address
🏁 Script executed:
#!/bin/bash
# Search for the actual method signatures to verify the correct usage
ast-grep --pattern 'func ($$$) FetchTokenPairByERC20Address($$$) $$$'
ast-grep --pattern 'func ($$$) FetchTokenPairByDenom($$$) $$$'Length of output: 1955
Use the Denomination-based Query Method
The example is invoking the ERC20‐address variant with a token denomination. To query by “usdt” (a bank denom), switch to FetchTokenPairByDenom.
Files needing update:
- examples/chain/erc20/query/2_TokenPairByDenom/example.go: line 61
Suggested diff:
- res, err := chainClient.FetchTokenPairByERC20Address(ctx, "usdt")
+ res, err := chainClient.FetchTokenPairByDenom(ctx, "usdt")📝 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.
| res, err := chainClient.FetchTokenPairByERC20Address(ctx, "usdt") | |
| res, err := chainClient.FetchTokenPairByDenom(ctx, "usdt") |
🤖 Prompt for AI Agents
In examples/chain/erc20/query/2_TokenPairByDenom/example.go at line 61, the
method FetchTokenPairByERC20Address is incorrectly called with a token
denomination "usdt". Replace this call with FetchTokenPairByDenom passing "usdt"
as the parameter to correctly query by denomination instead of ERC20 address.
Solves CP-395
Summary by CodeRabbit
New Features
Tests
Chores
Style