-
Notifications
You must be signed in to change notification settings - Fork 43
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
Release/release distribution exchange examples #210
Release/release distribution exchange examples #210
Conversation
…_50_1 Fix/sync dev with master 1.50.1
… `distribution` module
…le_examples Feat/add distribution module examples
…at/add_chain_exchange_module_examples
…dule_examples feat/add_chain_exchange_module_examples
… release/release_distribution_exchange_examples
WalkthroughThe update introduces a comprehensive suite of functionalities for automated chat interactions and blockchain-based voting and trading operations. It enhances the system's ability to handle distribution and exchange modules within a blockchain network, specifically targeting the InjectiveLabs and Cosmos SDK frameworks. Additionally, it adjusts trading parameters across different network environments and expands the system's querying capabilities for various blockchain-related information. 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 @@
## master #210 +/- ##
==========================================
- Coverage 29.71% 25.01% -4.71%
==========================================
Files 17 17
Lines 2564 3022 +458
==========================================
- Hits 762 756 -6
- Misses 1766 2234 +468
+ Partials 36 32 -4 ☔ View full report in Codecov by Sentry. |
res, err := chainClient.FetchChainPositions(ctx) | ||
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.
The error from chainClient.FetchChainPositions(ctx)
is only printed, lacking comprehensive error handling. Enhance error management by considering program exit or retry mechanisms.
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 values in the Cosmos keyring initialization present a security issue. Leverage environment variables or configuration files for handling sensitive data.
res, err := chainClient.FetchTradeRewardCampaign(ctx) | ||
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.
Minimal error handling for chainClient.FetchTradeRewardCampaign(ctx)
is observed, with only error printing. Consider implementing more robust error handling strategies.
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 values for Cosmos keyring initialization is a security concern. Employ environment variables or configuration files to securely manage sensitive information.
res, err := chainClient.FetchFeeDiscountSchedule(ctx) | ||
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.
The error handling for chainClient.FetchFeeDiscountSchedule(ctx)
is limited to printing the error. Enhance error management with more comprehensive strategies.
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 values in Cosmos keyring initialization pose a security risk. Use environment variables or configuration files for secure management of sensitive data.
res, err := chainClient.FetchBalanceMismatches(ctx, 1) | ||
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.
Error handling for chainClient.FetchBalanceMismatches(ctx, 1)
is minimal, with only error printing. Consider more robust error handling approaches.
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.
Using hardcoded values for Cosmos keyring initialization is a security issue. Consider environment variables or configuration files for secure handling of sensitive information.
res, err := chainClient.FetchExchangeBalances(ctx) | ||
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.
The error handling for chainClient.FetchExchangeBalances(ctx)
is limited to printing the error. Implement more comprehensive error handling strategies for better robustness.
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 values in the initialization of the Cosmos keyring are a security concern. Opt for environment variables or configuration files to securely manage sensitive data.
res, err := chainClient.FetchBalanceWithBalanceHolds(ctx) | ||
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.
Error handling for chainClient.FetchBalanceWithBalanceHolds(ctx)
is minimal, only involving error printing. Consider adopting more robust error handling techniques.
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 practice of using hardcoded values for Cosmos keyring initialization is a security risk. Employ environment variables or configuration files for the secure handling of sensitive information.
res, err := chainClient.FetchFeeDiscountTierStatistics(ctx) | ||
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.
The error handling for chainClient.FetchFeeDiscountTierStatistics(ctx)
is limited to printing the error. More comprehensive error handling strategies should be considered.
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 private key is hardcoded in the source code, which poses a significant security risk. Hardcoding sensitive information like private keys can lead to accidental exposure and misuse. It's recommended to use environment variables or secure vaults for managing sensitive data.
res, err := chainClient.FetchChainExpiryFuturesMarketInfo(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 for the chainClient.FetchChainExpiryFuturesMarketInfo
function call. Currently, if an error occurs, it's printed to the console, but the program will continue to execute and attempt to marshal a potentially nil res
variable, which could lead to a runtime panic. Consider adding a return
statement after printing the error to prevent further execution in case of an 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.FetchChainExpiryFuturesMarketInfo(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchChainExpiryFuturesMarketInfo(ctx, marketId) | |
if err != nil { | |
fmt.Println(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.
As with the previous file, the private key is hardcoded, which is a critical security issue. Always avoid hardcoding sensitive information in the source code. Use environment variables or secure vaults to manage such data securely.
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
) in the source code raises a significant security concern. Hardcoding sensitive information like private keys can lead to security vulnerabilities and should be avoided. Consider using environment variables or secure vaults to manage sensitive data.
res, err := chainClient.FetchValidatorDistributionInfo(ctx, validatorAddress) | ||
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 for the chainClient.FetchValidatorDistributionInfo
call. Currently, if an error occurs, it is printed, but the program will continue to execute and attempt to marshal a potentially nil res
. This could lead to a runtime panic. Consider adding a return
statement after printing the error to prevent further execution in case of an 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.FetchValidatorDistributionInfo(ctx, validatorAddress) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchValidatorDistributionInfo(ctx, validatorAddress) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} |
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.
As with the previous file, the hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e
) presents a security risk. Avoid hardcoding sensitive information in the source code. Use environment variables or secure vaults for managing sensitive data.
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.
Proper error handling is missing for the chainClient.FetchDerivativeMidPriceAndTOB
call. If an error occurs, it's printed, but the program will still attempt to marshal and print res
, which could be nil and lead to a runtime panic. Consider halting execution with a return
statement after printing the 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.FetchDerivativeMidPriceAndTOB(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchDerivativeMidPriceAndTOB(ctx, marketId) | |
if err != nil { | |
fmt.Println(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.
The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e
) is a security issue. Hardcoding sensitive information like private keys in the source code can lead to security vulnerabilities. Consider using environment variables or secure vaults for managing sensitive data.
res, err := chainClient.FetchValidatorOutstandingRewards(ctx, validatorAddress) | ||
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 for the chainClient.FetchValidatorOutstandingRewards
call is insufficient. If an error occurs, it's printed, but the program will still attempt to marshal and print res
, which could be nil, potentially causing a runtime panic. It's advisable to halt execution with a return
statement after printing the 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.FetchValidatorOutstandingRewards(ctx, validatorAddress) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchValidatorOutstandingRewards(ctx, validatorAddress) | |
if err != nil { | |
fmt.Println(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.
The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e
) is a security risk. Hardcoding sensitive information in the source code can lead to security vulnerabilities. Use environment variables or secure vaults for managing sensitive data instead.
res, err := chainClient.FetchChainDerivativeMarket(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.
The error handling for the chainClient.FetchChainDerivativeMarket
call is inadequate. If an error occurs, it's printed, but the program will still attempt to marshal and print res
, which could be nil, potentially causing a runtime panic. Consider halting execution with a return
statement after printing the 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.FetchChainDerivativeMarket(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchChainDerivativeMarket(ctx, marketId) | |
if err != nil { | |
fmt.Println(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.
The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e
) is a security concern. Avoid hardcoding sensitive information like private keys in the source code. Use environment variables or secure vaults for managing sensitive data.
res, err := chainClient.FetchAggregateMarketVolume(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.
The error handling for the chainClient.FetchAggregateMarketVolume
call is insufficient. If an error occurs, it's printed, but the program will still attempt to marshal and print res
, which could be nil, potentially causing a runtime panic. It's advisable to halt execution with a return
statement after printing the 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.FetchAggregateMarketVolume(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchAggregateMarketVolume(ctx, marketId) | |
if err != nil { | |
fmt.Println(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.
The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e
) is a security issue. Hardcoding sensitive information in the source code can lead to security vulnerabilities. Consider using environment variables or secure vaults for managing sensitive data.
res, err := chainClient.FetchHistoricalTradeRecords(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.
The error handling for the chainClient.FetchHistoricalTradeRecords
call is inadequate. If an error occurs, it's printed, but the program will still attempt to marshal and print res
, which could be nil, potentially causing a runtime panic. Consider halting execution with a return
statement after printing the 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.FetchHistoricalTradeRecords(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchHistoricalTradeRecords(ctx, marketId) | |
if err != nil { | |
fmt.Println(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.
The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e
) is a security risk. Hardcoding sensitive information in the source code can lead to security vulnerabilities. Use environment variables or secure vaults for managing sensitive data instead.
res, err := chainClient.FetchDerivativeMarketAddress(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.
The error handling for the chainClient.FetchDerivativeMarketAddress
call is insufficient. If an error occurs, it's printed, but the program will still attempt to marshal and print res
, which could be nil, potentially causing a runtime panic. Consider halting execution with a return
statement after printing the 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.FetchDerivativeMarketAddress(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchDerivativeMarketAddress(ctx, marketId) | |
if err != nil { | |
fmt.Println(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.
The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e
) is a security concern. Avoid hardcoding sensitive information like private keys in the source code. Use environment variables or secure vaults for managing sensitive data.
res, err := chainClient.FetchChainPerpetualMarketInfo(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.
The error handling for the chainClient.FetchChainPerpetualMarketInfo
call is inadequate. If an error occurs, it's printed, but the program will still attempt to marshal and print res
, which could be nil, potentially causing a runtime panic. Consider halting execution with a return
statement after printing the 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.FetchChainPerpetualMarketInfo(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchChainPerpetualMarketInfo(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx, err := chainclient.NewClientContext( | ||
network.ChainId, | ||
senderAddress.String(), | ||
cosmosKeyring, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | ||
|
||
chainClient, err := chainclient.NewChainClient( | ||
clientCtx, | ||
network, | ||
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
ctx := context.Background() | ||
|
||
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" | ||
limit := uint64(2) | ||
limitCumulativeNotional := cosmostypes.Dec{} | ||
|
||
res, err := chainClient.FetchChainDerivativeOrderbook(ctx, marketId, limit, limitCumulativeNotional) | ||
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.
In the examples/chain/exchange/query/22_DerivativeOrderbook/example.go
file, the error handling after the JSON marshalling operation (line 72) is missing. It's a good practice to always check for errors after operations that can fail, such as JSON marshalling, to ensure the robustness of the code.
- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+ fmt.Println("Error marshalling JSON:", 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) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"inj-user", | |
"12345678", | |
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | |
) | |
if err != nil { | |
panic(err) | |
} | |
ctx := context.Background() | |
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" | |
limit := uint64(2) | |
limitCumulativeNotional := cosmostypes.Dec{} | |
res, err := chainClient.FetchChainDerivativeOrderbook(ctx, marketId, limit, limitCumulativeNotional) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
str, err := json.MarshalIndent(res, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", 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.
The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e
) is a security issue. Hardcoding sensitive information in the source code can lead to security vulnerabilities. Consider using environment variables or secure vaults for managing sensitive data.
res, err := chainClient.FetchSubaccountDeposit(ctx, subaccountId.Hex(), denom) | ||
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 for the chainClient.FetchSubaccountDeposit
call is insufficient. If an error occurs, it's printed, but the program will still attempt to marshal and print res
, which could be nil, potentially causing a runtime panic. Consider halting execution with a return
statement after printing the 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.FetchSubaccountDeposit(ctx, subaccountId.Hex(), denom) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchSubaccountDeposit(ctx, subaccountId.Hex(), denom) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx, err := chainclient.NewClientContext( | ||
network.ChainId, | ||
senderAddress.String(), | ||
cosmosKeyring, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | ||
|
||
chainClient, err := chainclient.NewChainClient( | ||
clientCtx, | ||
network, | ||
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
withdrawAddress := "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r" | ||
|
||
msg := &types.MsgSetWithdrawAddress{ | ||
DelegatorAddress: senderAddress.String(), | ||
WithdrawAddress: withdrawAddress, | ||
} | ||
|
||
//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg | ||
response, err := chainClient.AsyncBroadcastMsg(msg) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
str, _ := json.MarshalIndent(response, "", " ") | ||
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.
In the examples/chain/distribution/1_SetWithdrawAddress/example.go
file, the error handling after the JSON marshalling operation (line 73) is missing. It's important to handle errors returned by the json.MarshalIndent
function to catch any potential issues during the marshalling process.
- str, _ := json.MarshalIndent(response, "", " ")
+ str, err := json.MarshalIndent(response, "", " ")
+ if err != nil {
+ fmt.Println("Error marshalling JSON:", 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) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"inj-user", | |
"12345678", | |
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | |
) | |
if err != nil { | |
panic(err) | |
} | |
withdrawAddress := "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r" | |
msg := &types.MsgSetWithdrawAddress{ | |
DelegatorAddress: senderAddress.String(), | |
WithdrawAddress: withdrawAddress, | |
} | |
//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg | |
response, err := chainClient.AsyncBroadcastMsg(msg) | |
if err != nil { | |
panic(err) | |
} | |
str, _ := json.MarshalIndent(response, "", " ") | |
fmt.Print(string(str)) | |
str, err := json.MarshalIndent(response, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", 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 hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e
) is a security risk. Hardcoding sensitive information in the source code can lead to security vulnerabilities. Use environment variables or secure vaults for managing sensitive data instead.
res, err := chainClient.FetchChainPerpetualMarketFunding(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.
The error handling for the chainClient.FetchChainPerpetualMarketFunding
call is inadequate. If an error occurs, it's printed, but the program will still attempt to marshal and print res
, which could be nil, potentially causing a runtime panic. Consider halting execution with a return
statement after printing the 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.FetchChainPerpetualMarketFunding(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
} | |
res, err := chainClient.FetchChainPerpetualMarketFunding(ctx, marketId) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx, err := chainclient.NewClientContext( | ||
network.ChainId, | ||
senderAddress.String(), | ||
cosmosKeyring, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | ||
|
||
chainClient, err := chainclient.NewChainClient( | ||
clientCtx, | ||
network, | ||
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
ctx := context.Background() | ||
|
||
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" | ||
subaccountId := chainClient.Subaccount(senderAddress, 0) | ||
orderHashes := []string{"0x57a01cd26f1e2080860af3264e865d7c9c034a701e30946d01c1dc7a303cf2c1"} | ||
|
||
res, err := chainClient.FetchChainSpotOrdersByHashes(ctx, marketId, subaccountId.Hex(), orderHashes) | ||
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.
In the examples/chain/exchange/query/17_SpotOrdersByHashes/example.go
file, the error handling after the JSON marshalling operation (line 69) is missing. Proper error handling is crucial for identifying issues during the marshalling process and ensuring the program's reliability.
- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+ fmt.Println("Error marshalling JSON:", 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) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"inj-user", | |
"12345678", | |
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | |
) | |
if err != nil { | |
panic(err) | |
} | |
ctx := context.Background() | |
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" | |
subaccountId := chainClient.Subaccount(senderAddress, 0) | |
orderHashes := []string{"0x57a01cd26f1e2080860af3264e865d7c9c034a701e30946d01c1dc7a303cf2c1"} | |
res, err := chainClient.FetchChainSpotOrdersByHashes(ctx, marketId, subaccountId.Hex(), orderHashes) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
str, err := json.MarshalIndent(res, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", err) | |
return | |
} |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx, err := chainclient.NewClientContext( | ||
network.ChainId, | ||
senderAddress.String(), | ||
cosmosKeyring, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | ||
|
||
chainClient, err := chainclient.NewChainClient( | ||
clientCtx, | ||
network, | ||
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
validatorAddress := "injvaloper1jue5dpr9lerjn6wlwtrywxrsenrf28ru89z99z" | ||
startingHeight := uint64(0) | ||
endingHeight := uint64(0) | ||
pagination := query.PageRequest{Limit: 10} | ||
ctx := context.Background() | ||
|
||
res, err := chainClient.FetchValidatorSlashes(ctx, validatorAddress, startingHeight, endingHeight, &pagination) | ||
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.
In the examples/chain/distribution/query/4_ValidatorSlashes/example.go
file, the error handling after the JSON marshalling operation (line 71) is missing. Proper error handling is essential for catching any issues that may occur during the marshalling process, which can help in debugging and ensuring the program's robustness.
- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+ fmt.Println("Error marshalling JSON:", 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) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"inj-user", | |
"12345678", | |
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | |
) | |
if err != nil { | |
panic(err) | |
} | |
validatorAddress := "injvaloper1jue5dpr9lerjn6wlwtrywxrsenrf28ru89z99z" | |
startingHeight := uint64(0) | |
endingHeight := uint64(0) | |
pagination := query.PageRequest{Limit: 10} | |
ctx := context.Background() | |
res, err := chainClient.FetchValidatorSlashes(ctx, validatorAddress, startingHeight, endingHeight, &pagination) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
str, err := json.MarshalIndent(res, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", err) | |
return | |
} | |
fmt.Print(string(str)) |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx, err := chainclient.NewClientContext( | ||
network.ChainId, | ||
senderAddress.String(), | ||
cosmosKeyring, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | ||
|
||
chainClient, err := chainclient.NewChainClient( | ||
clientCtx, | ||
network, | ||
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
ctx := context.Background() | ||
|
||
subaccountId := chainClient.Subaccount(senderAddress, 0) | ||
|
||
res, err := chainClient.FetchAggregateVolume(ctx, senderAddress.String()) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
str, _ := json.MarshalIndent(res, "", " ") | ||
fmt.Print(string(str)) | ||
|
||
res, err = chainClient.FetchAggregateVolume(ctx, subaccountId.Hex()) | ||
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.
In the examples/chain/exchange/query/4_AggregateVolume/example.go
file, the error handling after both JSON marshalling operations (lines 68 and 76) is missing. It's crucial to handle errors returned by the json.MarshalIndent
function to catch any potential issues during the marshalling process and ensure the program's reliability.
- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+ fmt.Println("Error marshalling JSON:", err)
+ return
+ }
This change should be applied after both marshalling operations in the file.
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) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"inj-user", | |
"12345678", | |
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | |
) | |
if err != nil { | |
panic(err) | |
} | |
ctx := context.Background() | |
subaccountId := chainClient.Subaccount(senderAddress, 0) | |
res, err := chainClient.FetchAggregateVolume(ctx, senderAddress.String()) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
res, err = chainClient.FetchAggregateVolume(ctx, subaccountId.Hex()) | |
if err != nil { | |
fmt.Println(err) | |
} | |
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) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"inj-user", | |
"12345678", | |
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | |
) | |
if err != nil { | |
panic(err) | |
} | |
ctx := context.Background() | |
subaccountId := chainClient.Subaccount(senderAddress, 0) | |
res, err := chainClient.FetchAggregateVolume(ctx, senderAddress.String()) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, err := json.MarshalIndent(res, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", err) | |
return | |
} | |
fmt.Print(string(str)) | |
res, err = chainClient.FetchAggregateVolume(ctx, subaccountId.Hex()) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, err = json.MarshalIndent(res, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", err) | |
return | |
} | |
fmt.Print(string(str)) | |
} |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx, err := chainclient.NewClientContext( | ||
network.ChainId, | ||
senderAddress.String(), | ||
cosmosKeyring, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | ||
|
||
chainClient, err := chainclient.NewChainClient( | ||
clientCtx, | ||
network, | ||
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
ctx := context.Background() | ||
|
||
marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" | ||
subaccountId := chainClient.Subaccount(senderAddress, 0) | ||
orderHashes := []string{"0x57a01cd26f1e2080860af3264e865d7c9c034a701e30946d01c1dc7a303cf2c1"} | ||
|
||
res, err := chainClient.FetchChainDerivativeOrdersByHashes(ctx, marketId, subaccountId.Hex(), orderHashes) | ||
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.
In the examples/chain/exchange/query/25_DerivativeOrdersByHashes/example.go
file, the error handling after the JSON marshalling operation (line 69) is missing. Proper error handling is essential for catching any issues that may occur during the marshalling process, which can help in debugging and ensuring the program's robustness.
- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+ fmt.Println("Error marshalling JSON:", 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) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"inj-user", | |
"12345678", | |
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | |
) | |
if err != nil { | |
panic(err) | |
} | |
ctx := context.Background() | |
marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" | |
subaccountId := chainClient.Subaccount(senderAddress, 0) | |
orderHashes := []string{"0x57a01cd26f1e2080860af3264e865d7c9c034a701e30946d01c1dc7a303cf2c1"} | |
res, err := chainClient.FetchChainDerivativeOrdersByHashes(ctx, marketId, subaccountId.Hex(), orderHashes) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
str, err := json.MarshalIndent(res, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", err) | |
return | |
} | |
fmt.Print(string(str)) |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx, err := chainclient.NewClientContext( | ||
network.ChainId, | ||
senderAddress.String(), | ||
cosmosKeyring, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | ||
|
||
chainClient, err := chainclient.NewChainClient( | ||
clientCtx, | ||
network, | ||
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
amount := types.NewCoin("inj", types.NewInt(1)) | ||
|
||
msg := &distriutiontypes.MsgFundCommunityPool{ | ||
Amount: []types.Coin{amount}, | ||
Depositor: senderAddress.String(), | ||
} | ||
|
||
//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg | ||
response, err := chainClient.AsyncBroadcastMsg(msg) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
str, _ := json.MarshalIndent(response, "", " ") | ||
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.
In the examples/chain/distribution/4_FundCommunityPool/example.go
file, the error handling after the JSON marshalling operation (line 74) is missing. It's important to handle errors returned by the json.MarshalIndent
function to catch any potential issues during the marshalling process and ensure the program's reliability.
- str, _ := json.MarshalIndent(response, "", " ")
+ str, err := json.MarshalIndent(response, "", " ")
+ if err != nil {
+ fmt.Println("Error marshalling JSON:", 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) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"inj-user", | |
"12345678", | |
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | |
) | |
if err != nil { | |
panic(err) | |
} | |
amount := types.NewCoin("inj", types.NewInt(1)) | |
msg := &distriutiontypes.MsgFundCommunityPool{ | |
Amount: []types.Coin{amount}, | |
Depositor: senderAddress.String(), | |
} | |
//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg | |
response, err := chainClient.AsyncBroadcastMsg(msg) | |
if err != nil { | |
panic(err) | |
} | |
str, _ := json.MarshalIndent(response, "", " ") | |
fmt.Print(string(str)) | |
str, err := json.MarshalIndent(response, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", err) | |
return | |
} | |
fmt.Print(string(str)) |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx, err := chainclient.NewClientContext( | ||
network.ChainId, | ||
senderAddress.String(), | ||
cosmosKeyring, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | ||
|
||
chainClient, err := chainclient.NewChainClient( | ||
clientCtx, | ||
network, | ||
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
ctx := context.Background() | ||
|
||
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" | ||
tradeHistoryOptions := types.TradeHistoryOptions{ | ||
TradeGroupingSec: 10, | ||
MaxAge: 0, | ||
IncludeRawHistory: true, | ||
IncludeMetadata: true, | ||
} | ||
|
||
res, err := chainClient.FetchMarketVolatility(ctx, marketId, &tradeHistoryOptions) | ||
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.
In the examples/chain/exchange/query/52_MarketVolatility/example.go
file, the error handling after the JSON marshalling operation (line 76) is missing. Proper error handling is crucial for identifying issues during the marshalling process and ensuring the program's reliability.
- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+ fmt.Println("Error marshalling JSON:", 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) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"inj-user", | |
"12345678", | |
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | |
) | |
if err != nil { | |
panic(err) | |
} | |
ctx := context.Background() | |
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" | |
tradeHistoryOptions := types.TradeHistoryOptions{ | |
TradeGroupingSec: 10, | |
MaxAge: 0, | |
IncludeRawHistory: true, | |
IncludeMetadata: true, | |
} | |
res, err := chainClient.FetchMarketVolatility(ctx, marketId, &tradeHistoryOptions) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
str, err := json.MarshalIndent(res, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", err) | |
return | |
} |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"inj-user", | ||
"12345678", | ||
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | ||
false, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx, err := chainclient.NewClientContext( | ||
network.ChainId, | ||
senderAddress.String(), | ||
cosmosKeyring, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | ||
|
||
chainClient, err := chainclient.NewChainClient( | ||
clientCtx, | ||
network, | ||
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
ctx := context.Background() | ||
|
||
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" | ||
limit := uint64(2) | ||
orderSide := types.OrderSide_Buy | ||
limitCumulativeNotional := cosmostypes.Dec{} | ||
limitCumulativeQuantity := cosmostypes.Dec{} | ||
|
||
res, err := chainClient.FetchChainSpotOrderbook(ctx, marketId, limit, orderSide, limitCumulativeNotional, limitCumulativeQuantity) | ||
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.
In the examples/chain/exchange/query/14_SpotOrderbook/example.go
file, the error handling after the JSON marshalling operation (line 75) is missing. It's a good practice to always check for errors after operations that can fail, such as JSON marshalling, to ensure the robustness of the code.
- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+ fmt.Println("Error marshalling JSON:", 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) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"inj-user", | |
"12345678", | |
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionGasPrices(client.DefaultGasPriceWithDenom), | |
) | |
if err != nil { | |
panic(err) | |
} | |
ctx := context.Background() | |
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" | |
limit := uint64(2) | |
orderSide := types.OrderSide_Buy | |
limitCumulativeNotional := cosmostypes.Dec{} | |
limitCumulativeQuantity := cosmostypes.Dec{} | |
res, err := chainClient.FetchChainSpotOrderbook(ctx, marketId, limit, orderSide, limitCumulativeNotional, limitCumulativeQuantity) | |
if err != nil { | |
fmt.Println(err) | |
} | |
str, _ := json.MarshalIndent(res, "", " ") | |
fmt.Print(string(str)) | |
str, err := json.MarshalIndent(res, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", err) | |
return | |
} | |
fmt.Print(string(str)) |
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | ||
os.Getenv("HOME")+"/.injectived", | ||
"injectived", | ||
"file", | ||
"gov_account", | ||
"", | ||
"", // keyring will be used if pk not provided | ||
false, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx, err := chainclient.NewClientContext( | ||
network.ChainId, | ||
senderAddress.String(), | ||
cosmosKeyring, | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | ||
|
||
txFactory := chainclient.NewTxFactory(clientCtx) | ||
txFactory = txFactory.WithGasPrices(client.DefaultGasPriceWithDenom) | ||
chainClient, err := chainclient.NewChainClient( | ||
clientCtx, | ||
network, | ||
common.OptionTxFactory(&txFactory), | ||
) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// note that we use grantee keyring to send the msg on behalf of granter here | ||
// sender, subaccount are from granter | ||
validators := []string{"inj156t3yxd4udv0h9gwagfcmwnmm3quy0npqc7pks", "inj16nd8yqxe9p6ggnrz58qr7dxn5y2834yendward"} | ||
grantee := senderAddress.String() | ||
proposalId := uint64(375) | ||
var msgs []sdk.Msg | ||
|
||
for _, validator := range validators { | ||
msgVote := v1beta1.MsgVote{ | ||
ProposalId: proposalId, | ||
Voter: validator, | ||
Option: v1beta1.OptionYes, | ||
} | ||
|
||
msg0Bytes, _ := msgVote.Marshal() | ||
msg0Any := &codectypes.Any{} | ||
msg0Any.TypeUrl = sdk.MsgTypeURL(&msgVote) | ||
msg0Any.Value = msg0Bytes | ||
|
||
msg := &authztypes.MsgExec{ | ||
Grantee: grantee, | ||
Msgs: []*codectypes.Any{msg0Any}, | ||
} | ||
|
||
sdkMsg := sdk.Msg(msg) | ||
msgs = append(msgs, sdkMsg) | ||
} | ||
|
||
//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg | ||
response, err := chainClient.AsyncBroadcastMsg(msgs...) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
str, _ := json.MarshalIndent(response, "", " ") | ||
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.
In the auth_vote/authz_vote.go
file, the error handling after the JSON marshalling operation (line 102) is missing. Proper error handling is essential for catching any issues that may occur during the marshalling process, which can help in debugging and ensuring the program's robustness.
- str, _ := json.MarshalIndent(response, "", " ")
+ str, err := json.MarshalIndent(response, "", " ")
+ if err != nil {
+ fmt.Println("Error marshalling JSON:", 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) | |
} | |
if err != nil { | |
panic(err) | |
} | |
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( | |
os.Getenv("HOME")+"/.injectived", | |
"injectived", | |
"file", | |
"gov_account", | |
"", | |
"", // keyring will be used if pk not provided | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx, err := chainclient.NewClientContext( | |
network.ChainId, | |
senderAddress.String(), | |
cosmosKeyring, | |
) | |
if err != nil { | |
panic(err) | |
} | |
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) | |
txFactory := chainclient.NewTxFactory(clientCtx) | |
txFactory = txFactory.WithGasPrices(client.DefaultGasPriceWithDenom) | |
chainClient, err := chainclient.NewChainClient( | |
clientCtx, | |
network, | |
common.OptionTxFactory(&txFactory), | |
) | |
if err != nil { | |
panic(err) | |
} | |
// note that we use grantee keyring to send the msg on behalf of granter here | |
// sender, subaccount are from granter | |
validators := []string{"inj156t3yxd4udv0h9gwagfcmwnmm3quy0npqc7pks", "inj16nd8yqxe9p6ggnrz58qr7dxn5y2834yendward"} | |
grantee := senderAddress.String() | |
proposalId := uint64(375) | |
var msgs []sdk.Msg | |
for _, validator := range validators { | |
msgVote := v1beta1.MsgVote{ | |
ProposalId: proposalId, | |
Voter: validator, | |
Option: v1beta1.OptionYes, | |
} | |
msg0Bytes, _ := msgVote.Marshal() | |
msg0Any := &codectypes.Any{} | |
msg0Any.TypeUrl = sdk.MsgTypeURL(&msgVote) | |
msg0Any.Value = msg0Bytes | |
msg := &authztypes.MsgExec{ | |
Grantee: grantee, | |
Msgs: []*codectypes.Any{msg0Any}, | |
} | |
sdkMsg := sdk.Msg(msg) | |
msgs = append(msgs, sdkMsg) | |
} | |
//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg | |
response, err := chainClient.AsyncBroadcastMsg(msgs...) | |
if err != nil { | |
panic(err) | |
} | |
str, _ := json.MarshalIndent(response, "", " ") | |
fmt.Print(string(str)) | |
str, err := json.MarshalIndent(response, "", " ") | |
if err != nil { | |
fmt.Println("Error marshalling JSON:", err) | |
return | |
} | |
fmt.Print(string(str)) |
dev
branch related to the distribution and chain exchange modules intomaster
Summary by CodeRabbit
New Features
.coderabbit.yaml
.Enhancements
Documentation