-
Notifications
You must be signed in to change notification settings - Fork 46
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/add_chain_exchange_module_examples #209
Conversation
…at/add_chain_exchange_module_examples
WalkthroughThe recent updates focus on enhancing the blockchain network's voting mechanism and the Injective Protocol chain's functionality. These changes introduce a more robust voting process for blockchain proposals and significantly improve the chain's exchange module. They streamline market launching, reward management, and data querying across various market types and financial operations, making the system more efficient and user-friendly. Changes
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 (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #209 +/- ##
==========================================
- Coverage 29.01% 25.01% -4.00%
==========================================
Files 17 17
Lines 2630 3022 +392
==========================================
- Hits 763 756 -7
- Misses 1831 2234 +403
+ Partials 36 32 -4 ☔ View full report in Codecov by Sentry. |
res, err := chainClient.FetchChainSpotMarkets(ctx, status, marketIds) | ||
if err != nil { | ||
fmt.Println(err) | ||
} |
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 error handling in this example is minimal, only printing the error. Improving error handling would benefit users of this example.
Suggest adding more detailed error handling to provide better guidance on how to react to different error conditions.
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, |
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.
Identical to the previous files, this script contains hardcoded sensitive information in the InitCosmosKeyring
function. This is a security concern that needs addressing.
Recommend using environment variables or secure storage mechanisms for sensitive data like private keys and passwords.
res, err := chainClient.FetchChainFullSpotMarket(ctx, marketId, withMidPriceAndTob) | ||
if err != nil { | ||
fmt.Println(err) | ||
} |
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 error handling after the FetchChainFullSpotMarket
call is minimal, only printing the error. Enhancing error handling would make the example more robust and informative.
Consider adding error handling logic that could include logging the error or even retrying the operation depending on the error type.
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, |
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.
Again, this example includes hardcoded sensitive information in the InitCosmosKeyring
function, which is a consistent security issue across these examples.
Urging the use of environment variables or secure storage for managing sensitive data to avoid security risks.
res, err := chainClient.FetchAggregateVolumes(ctx, accounts, marketIds) | ||
if err != nil { | ||
fmt.Println(err) | ||
} |
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 error handling in this example is minimal, only printing the error. This could be enhanced to provide a more robust and informative example.
Recommend adding more detailed error handling to improve the example's usefulness and guide users on how to handle different error scenarios.
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} |
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.
Ensure proper error handling by not just panicking but also logging the error or providing a more user-friendly message. Panicking might not be the best approach for production code or examples meant for wider audiences.
- panic(err)
+ fmt.Printf("Error creating Tendermint HTTP client: %v\n", err)
+ return
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.
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
panic(err) | |
} | |
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Printf("Error creating Tendermint HTTP client: %v\n", err) | |
return | |
} |
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/InjectiveLabs/sdk-go/client" | ||
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | ||
"github.com/InjectiveLabs/sdk-go/client/common" | ||
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | ||
) |
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.
Consider organizing imports by grouping standard library imports separately from third-party packages for better readability.
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/InjectiveLabs/sdk-go/client"
chainclient "github.com/InjectiveLabs/sdk-go/client/chain"
"github.com/InjectiveLabs/sdk-go/client/common"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
)
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.
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
) | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
) | |
import ( | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
) |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) |
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 use of a hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e
) and password (12345678
) in the InitCosmosKeyring
function call raises security concerns. For example scripts, it's better to prompt the user for sensitive information or read from environment variables or configuration files.
Consider removing sensitive information and prompting the user or reading from a secure source.
res, err := chainClient.FetchFeeDiscountAccountInfo(ctx, senderAddress.String()) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
str, _ := json.MarshalIndent(res, "", " ") | ||
fmt.Print(string(str)) |
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.
Ensure error handling is comprehensive. Currently, if an error occurs when fetching fee discount account information (FetchFeeDiscountAccountInfo
), the error is printed, but the program continues to attempt marshalling potentially nil or incomplete data, which could lead to a runtime panic.
if err != nil {
fmt.Println(err)
+ return
}
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.
res, err := chainClient.FetchFeeDiscountAccountInfo(ctx, senderAddress.String()) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
res, err := chainClient.FetchFeeDiscountAccountInfo(ctx, senderAddress.String()) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) |
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.
Storing sensitive information such as the keyring passphrase ("12345678"
) and the private key directly in the source code is a security risk. Consider using environment variables or a secure vault service for handling sensitive data.
res, err := chainClient.FetchMitoVaultInfos(ctx) | ||
if err != nil { | ||
fmt.Println(err) | ||
} |
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.
When handling errors, it's good practice to provide more context about the error. Simply printing the error might not be enough for debugging purposes. Consider logging the specific operation that failed along with the error message.
- fmt.Println(err)
+ fmt.Printf("Error fetching MitoVault information: %v\n", err)
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.
res, err := chainClient.FetchMitoVaultInfos(ctx) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchMitoVaultInfos(ctx) | |
if err != nil { | |
fmt.Printf("Error fetching MitoVault information: %v\n", err) | |
} |
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
|
||
"os" | ||
|
||
"github.com/InjectiveLabs/sdk-go/client" | ||
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | ||
"github.com/InjectiveLabs/sdk-go/client/common" | ||
rpchttp "github.com/cometbft/cometbft/rpc/client/http" |
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.
As with the previous file, consider organizing imports by grouping standard library imports separately from third-party packages for better readability.
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/InjectiveLabs/sdk-go/client"
chainclient "github.com/InjectiveLabs/sdk-go/client/chain"
"github.com/InjectiveLabs/sdk-go/client/common"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
)
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.
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
) |
str, _ := json.MarshalIndent(res, "", " ") | ||
fmt.Print(string(str)) |
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.
While ignoring errors from json.MarshalIndent
might be acceptable in simple examples, it's generally a good practice to handle every error. This can prevent silent failures and make debugging easier.
- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+ fmt.Printf("Error marshalling response: %v\n", err)
+ return
+ }
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.
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
str, err := json.MarshalIndent(res, "", " ") | |
if err != nil { | |
fmt.Printf("Error marshalling response: %v\n", err) | |
return | |
} | |
fmt.Print(string(str)) |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, |
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 use of hardcoded sensitive information is a security risk. Consider prompting the user for this information or reading it from a secure source.
Consider removing sensitive information and prompting the user or reading from a secure source.
res, err := chainClient.FetchIsOptedOutOfRewards(ctx, senderAddress.String()) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
str, _ := json.MarshalIndent(res, "", " ") | ||
fmt.Print(string(str)) |
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.
Ensure comprehensive error handling. If an error occurs, the program should not attempt to marshal and print potentially nil or incomplete data.
if err != nil {
fmt.Println(err)
+ return
}
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.
res, err := chainClient.FetchIsOptedOutOfRewards(ctx, senderAddress.String()) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
res, err := chainClient.FetchIsOptedOutOfRewards(ctx, senderAddress.String()) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) |
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.
As mentioned previously, consider improving error handling by providing more context or using a more graceful exit strategy than panicking.
- panic(err)
+ fmt.Printf("Error creating Tendermint HTTP client: %v\n", err)
+ return
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.
func main() { | |
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
panic(err) | |
func main() { | |
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Printf("Error creating Tendermint HTTP client: %v\n", err) | |
return |
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, |
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.
Avoid hardcoding sensitive information in the source code. Use environment variables or secure storage solutions for managing sensitive data like passphrases and private keys.
res, err := chainClient.FetchChainPositions(ctx) | ||
if err != nil { | ||
fmt.Println(err) |
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.
Provide more context when logging errors to aid in debugging. Simply printing the error may not be sufficient.
- fmt.Println(err)
+ fmt.Printf("Error fetching chain positions: %v\n", err)
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.
res, err := chainClient.FetchChainPositions(ctx) | |
if err != nil { | |
fmt.Println(err) | |
res, err := chainClient.FetchChainPositions(ctx) | |
if err != nil { | |
fmt.Printf("Error fetching chain positions: %v\n", err) |
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
|
||
"os" | ||
|
||
"github.com/InjectiveLabs/sdk-go/client" | ||
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | ||
"github.com/InjectiveLabs/sdk-go/client/common" | ||
rpchttp "github.com/cometbft/cometbft/rpc/client/http" |
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.
Group standard library imports separately from third-party packages for improved readability.
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/InjectiveLabs/sdk-go/client"
chainclient "github.com/InjectiveLabs/sdk-go/client/chain"
"github.com/InjectiveLabs/sdk-go/client/common"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
)
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.
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
) |
|
||
str, _ := json.MarshalIndent(res, "", " ") |
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.
Handle all errors, including those from json.MarshalIndent
, to avoid silent failures.
- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+ fmt.Printf("Error marshalling response: %v\n", err)
+ return
+ }
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.
str, _ := json.MarshalIndent(res, "", " ") | |
str, err := json.MarshalIndent(res, "", " ") | |
if err != nil { | |
fmt.Printf("Error marshalling response: %v\n", err) | |
return | |
} |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, |
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.
Avoid using hardcoded sensitive information. Instead, prompt the user or read from a secure source.
Consider removing sensitive information and prompting the user or reading from a secure source.
res, err := chainClient.FetchChainBinaryOptionsMarkets(ctx, status) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
str, _ := json.MarshalIndent(res, "", " ") | ||
fmt.Print(string(str)) |
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.
Ensure error handling is comprehensive to avoid attempting to marshal and print nil or incomplete data on error.
if err != nil {
fmt.Println(err)
+ return
}
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.
res, err := chainClient.FetchChainBinaryOptionsMarkets(ctx, status) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
res, err := chainClient.FetchChainBinaryOptionsMarkets(ctx, status) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) |
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} |
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.
Improve error handling by avoiding panics and providing more informative error messages.
- panic(err)
+ fmt.Printf("Error creating Tendermint HTTP client: %v\n", err)
+ return
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.
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
panic(err) | |
} | |
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Printf("Error creating Tendermint HTTP client: %v\n", err) | |
return | |
} |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} |
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.
Ensure proper error handling instead of using panic
. Consider logging the error and gracefully shutting down or retrying the operation.
- panic(err)
+ fmt.Println("Error creating Tendermint HTTP client:", err)
+ return
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.
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
panic(err) | |
} | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Println("Error creating Tendermint HTTP client:", err) | |
return | |
} |
res, err := chainClient.FetchChainSubaccountPositions(ctx, subaccountId.Hex()) | ||
if err != nil { | ||
fmt.Println(err) | ||
} |
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.
Add proper error handling after the main query to handle potential errors gracefully.
if err != nil {
fmt.Println("Error fetching subaccount positions:", err)
return
}
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.
res, err := chainClient.FetchChainSubaccountPositions(ctx, subaccountId.Hex()) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchChainSubaccountPositions(ctx, subaccountId.Hex()) | |
if err != nil { | |
fmt.Println("Error fetching subaccount positions:", err) | |
return | |
} |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} |
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.
Replace panic
with more appropriate error handling to enhance the script's robustness and user experience.
- panic(err)
+ fmt.Println("Error creating Tendermint HTTP client:", err)
+ return
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.
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
panic(err) | |
} | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Println("Error creating Tendermint HTTP client:", err) | |
return | |
} |
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/InjectiveLabs/sdk-go/client" | ||
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | ||
"github.com/InjectiveLabs/sdk-go/client/common" | ||
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | ||
) |
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.
Organize imports by grouping standard library imports separately from third-party packages for improved readability.
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/InjectiveLabs/sdk-go/client"
chainclient "github.com/InjectiveLabs/sdk-go/client/chain"
"github.com/InjectiveLabs/sdk-go/client/common"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
)
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.
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
) | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
) | |
import ( | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
) |
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
panic(err) |
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.
Improve error handling by avoiding panics and providing more informative error messages.
- panic(err)
+ fmt.Printf("Error creating Tendermint HTTP client: %v\n", err)
+ return
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.
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Println(err) | |
return | |
panic(err) | |
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Printf("Error creating Tendermint HTTP client: %v\n", err) | |
return |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) |
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.
Hardcoded sensitive information poses a security risk. Use environment variables or secure vaults to store such information.
if err != nil { | ||
panic(err) | ||
} |
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.
Adopt a more graceful approach to error handling instead of using panic
.
- panic(err)
+ fmt.Println("Error initializing Cosmos keyring:", err)
+ return
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.
if err != nil { | |
panic(err) | |
} | |
if err != nil { | |
fmt.Println("Error initializing Cosmos keyring:", err) | |
return | |
} |
if err != nil { | ||
panic(err) | ||
} |
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.
Replace panic
with proper error handling to improve the example script's usability and safety.
- panic(err)
+ fmt.Println("Error creating client context:", err)
+ return
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.
if err != nil { | |
panic(err) | |
} | |
if err != nil { | |
fmt.Println("Error creating client context:", err) | |
return | |
} |
@@ -45,11 +41,10 @@ func main() { | |||
) | |||
|
|||
if err != nil { | |||
fmt.Println(err) | |||
return | |||
panic(err) |
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.
As with previous files, consider handling errors more gracefully than panicking.
- panic(err)
+ fmt.Printf("Error initializing client context: %v\n", err)
+ return
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.
panic(err) | |
fmt.Printf("Error initializing client context: %v\n", err) | |
return |
if err != nil { | ||
panic(err) | ||
} |
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.
Consistent with previous comments, avoid using panic
for error handling.
- panic(err)
+ fmt.Println("Error creating chain client:", err)
+ return
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.
if err != nil { | |
panic(err) | |
} | |
if err != nil { | |
fmt.Println("Error creating chain client:", err) | |
return | |
} |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} |
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.
Adopt a more graceful error handling strategy instead of using panic
, to enhance the user experience by providing more context about the error.
- panic(err)
+ fmt.Printf("Error creating Tendermint HTTP client: %v\n", err)
+ return
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.
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
panic(err) | |
} | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Printf("Error creating Tendermint HTTP client: %v\n", err) | |
return | |
} |
} | ||
|
||
//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg | ||
err = chainClient.QueueBroadcastMsg(&liqMsg) | ||
err = chainClient.QueueBroadcastMsg(msg) |
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.
When broadcasting messages, it's important to handle errors properly. Consider adding a more descriptive error message to help with debugging.
- fmt.Println(err)
+ fmt.Printf("Error broadcasting MsgRewardsOptOut: %v\n", err)
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.
err = chainClient.QueueBroadcastMsg(msg) | |
fmt.Printf("Error broadcasting MsgRewardsOptOut: %v\n", err) |
if err != nil { | ||
fmt.Println(err) | ||
} |
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.
Handle errors more gracefully, potentially logging them for further investigation or retrying the operation as needed.
- fmt.Println(err)
+ fmt.Println("Error fetching trader derivative transient orders:", err)
+ return
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.
if err != nil { | |
fmt.Println(err) | |
} | |
if err != nil { | |
fmt.Println("Error fetching trader derivative transient orders:", err) | |
return | |
} |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) |
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.
Remove hard-coded values for the keyring setup and use environment variables or a configuration file for better security and flexibility.
res, err := chainClient.FetchSpotMidPriceAndTOB(ctx, marketId) | ||
if err != nil { | ||
fmt.Println(err) | ||
} |
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.
Ensure proper error handling after the main query to gracefully handle potential errors.
if err != nil {
fmt.Println("Error fetching spot mid price and TOB:", err)
return
}
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.
res, err := chainClient.FetchSpotMidPriceAndTOB(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchSpotMidPriceAndTOB(ctx, marketId) | |
if err != nil { | |
fmt.Println("Error fetching spot mid price and TOB:", err) | |
return | |
} |
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) |
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.
Replace panic
with more appropriate error handling to enhance the script's robustness and user experience.
- panic(err)
+ fmt.Println("Error creating Tendermint HTTP client:", err)
+ return
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.
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
panic(err) | |
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Println("Error creating Tendermint HTTP client:", err) | |
return |
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
|
||
"os" | ||
|
||
"github.com/InjectiveLabs/sdk-go/client" | ||
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | ||
"github.com/InjectiveLabs/sdk-go/client/common" | ||
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | ||
) |
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.
Group imports by separating standard library imports from third-party packages to improve code readability.
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/InjectiveLabs/sdk-go/client"
chainclient "github.com/InjectiveLabs/sdk-go/client/chain"
"github.com/InjectiveLabs/sdk-go/client/common"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
)
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.
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
) | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
) | |
import ( | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
) |
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, |
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.
Hardcoded sensitive information poses a security risk. Use environment variables or secure vaults to store such information.
|
||
if err != nil { | ||
panic(err) |
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.
Adopt a more graceful approach to error handling instead of using panic
.
- panic(err)
+ fmt.Println("Error initializing Cosmos keyring:", err)
+ return
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.
if err != nil { | |
panic(err) | |
if err != nil { | |
fmt.Println("Error initializing Cosmos keyring:", err) | |
return |
|
||
if err != nil { | ||
panic(err) |
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.
Replace panic
with proper error handling to improve the example script's usability and safety.
- panic(err)
+ fmt.Println("Error creating client context:", err)
+ return
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.
if err != nil { | |
panic(err) | |
if err != nil { | |
fmt.Println("Error creating client context:", err) | |
return |
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) |
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.
Replace panic
with a more graceful error handling approach to improve user experience and provide more context about the error.
- panic(err)
+ fmt.Printf("Error creating Tendermint HTTP client: %v\n", err)
+ return
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.
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
panic(err) | |
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Printf("Error creating Tendermint HTTP client: %v\n", err) | |
return |
|
||
if err != nil { | ||
panic(err) |
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.
Consistent with previous comments, avoid using panic
for error handling.
- panic(err)
+ fmt.Println("Error creating chain client:", err)
+ return
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.
if err != nil { | |
panic(err) | |
if err != nil { | |
fmt.Println("Error creating chain client:", err) | |
return |
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, |
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.
Avoid using hard-coded values for keyring setup. Use environment variables or a configuration file for better security and flexibility.
res, err := chainClient.FetchChainSpotMarket(ctx, marketId) | ||
if err != nil { | ||
fmt.Println(err) |
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.
Add proper error handling after the main query to handle potential errors gracefully.
if err != nil {
fmt.Println("Error fetching spot market information:", err)
return
}
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.
res, err := chainClient.FetchChainSpotMarket(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
res, err := chainClient.FetchChainSpotMarket(ctx, marketId) | |
if err != nil { | |
fmt.Println("Error fetching spot market information:", err) | |
return |
res, err := chainClient.FetchChainSubaccountPositionInMarket(ctx, subaccountId.Hex(), marketId) | ||
if err != nil { | ||
fmt.Println(err) |
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.
Handle errors more gracefully, potentially logging them for further investigation or retrying the operation as needed.
- fmt.Println(err)
+ fmt.Println("Error fetching subaccount position in market:", err)
+ return
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.
res, err := chainClient.FetchChainSubaccountPositionInMarket(ctx, subaccountId.Hex(), marketId) | |
if err != nil { | |
fmt.Println(err) | |
res, err := chainClient.FetchChainSubaccountPositionInMarket(ctx, subaccountId.Hex(), marketId) | |
if err != nil { | |
fmt.Println("Error fetching subaccount position in market:", err) | |
return |
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/InjectiveLabs/sdk-go/client" | ||
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | ||
"github.com/InjectiveLabs/sdk-go/client/common" | ||
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | ||
) |
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.
Organize imports by grouping standard library imports separately from third-party packages for better readability.
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/InjectiveLabs/sdk-go/client"
chainclient "github.com/InjectiveLabs/sdk-go/client/chain"
"github.com/InjectiveLabs/sdk-go/client/common"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
)
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.
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
"github.com/InjectiveLabs/sdk-go/client" | |
chainclient "github.com/InjectiveLabs/sdk-go/client/chain" | |
"github.com/InjectiveLabs/sdk-go/client/common" | |
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | |
) | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
) |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} |
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.
Adopt a more graceful error handling strategy instead of using panic
, to enhance user experience by providing more context about the error.
- panic(err)
+ fmt.Printf("Error creating Tendermint HTTP client: %v\n", err)
+ return
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.
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
panic(err) | |
} | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Printf("Error creating Tendermint HTTP client: %v\n", err) | |
return | |
} |
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) |
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.
Replace panic
with more appropriate error handling to enhance the script's robustness and user experience.
- panic(err)
+ fmt.Println("Error creating Tendermint HTTP client:", err)
+ return
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.
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
panic(err) | |
network := common.LoadNetwork("testnet", "lb") | |
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | |
if err != nil { | |
fmt.Println("Error creating Tendermint HTTP client:", err) | |
return |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) |
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.
Remove hard-coded values for the keyring setup and use environment variables or a configuration file for better security and flexibility.
res, err := chainClient.FetchDerivativeMidPriceAndTOB(ctx, marketId) | ||
if err != nil { | ||
fmt.Println(err) | ||
} |
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.
Ensure proper error handling after the main query to gracefully handle potential errors.
if err != nil {
fmt.Println("Error fetching derivative mid price and TOB:", err)
return
}
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.
res, err := chainClient.FetchDerivativeMidPriceAndTOB(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchDerivativeMidPriceAndTOB(ctx, marketId) | |
if err != nil { | |
fmt.Println("Error fetching derivative mid price and TOB:", err) | |
return | |
} |
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, |
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.
Hardcoded sensitive information poses a security risk. Use environment variables or secure vaults to store such information.
Summary by CodeRabbit
ChainClient
interface with new methods and data types for improved chain exchange interactions.