-
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
Merged
aarmoa
merged 10 commits into
master
from
release/release_distribution_exchange_examples
Mar 8, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bd9ffbe
Merge pull request #206 from InjectiveLabs/fix/sync_dev_with_master_1…
aarmoa 0e0b7a2
(feat) Added example script for all queries and messages in the chain…
1141d09
(fix) Added CodeRabbit configuration file
d64bc93
(fix) Fixed pre-commit issues
bb47a8f
Merge pull request #208 from InjectiveLabs/feat/add_distribution_modu…
aarmoa b70213c
(feat) Added example scripts for all chain exchange module queries an…
2701f15
Merge branch 'dev' of https://github.com/InjectiveLabs/sdk-go into fe…
061635d
Merge pull request #209 from InjectiveLabs/feat/add_chain_exchange_mo…
aarmoa 2e956b4
(fix) Updated denoms .ini files
2ccf24b
Merge branch 'master' of https://github.com/InjectiveLabs/sdk-go into…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
reviews: | ||
auto_review: | ||
base_branches: | ||
- "master" | ||
- "dev" | ||
- "feat/.*" | ||
chat: | ||
auto_reply: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package main | ||
|
||
import ( | ||
"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" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
authztypes "github.com/cosmos/cosmos-sdk/x/authz" | ||
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" | ||
) | ||
|
||
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)) | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.Committable suggestion