-
Notifications
You must be signed in to change notification settings - Fork 152
feat!: native core SDK command support #892
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
Merged
Merged
Changes from 28 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
1526481
add authz native support
reecepbcups 421b08c
`x/bank` support
reecepbcups 5342317
cleanup bank queries
reecepbcups 069779d
fix authz to SDK v50
reecepbcups c57a3c5
fix e2e
reecepbcups 46c1c39
WIP of todos
reecepbcups f20e1e8
full bank suite testing
reecepbcups c1d1d0d
fix test
reecepbcups 32e08ba
build TokenFactory off ChainNode
reecepbcups e6ea937
crisis, distr, slashing, and staking txs+queries
reecepbcups 2fb0a4f
updated todo
reecepbcups 720d1cd
move gRPC conn on node startup
reecepbcups d36acc8
rename all to modules_
reecepbcups 7d0bfe9
add circuit & feegrant txs + queries
reecepbcups 809d695
x/upgrade
reecepbcups c2a4a6c
WIP: x/gov
reecepbcups 4317009
distribution test
reecepbcups 59bf214
fix distribution
reecepbcups d5bee5e
Merge branch 'main' into reece/complete-core
reecepbcups f1c330e
backup
reecepbcups 264939e
comment out bad feegrant for now
reecepbcups fe405d2
govv1 & govv1beta1 query types
reecepbcups 03e390c
add SDK v50 gov test
reecepbcups c6cdd0c
wip: circuit
reecepbcups 8648f3c
move cosmwasm to its own module section
reecepbcups 059a87e
Add `x/auth` queries
reecepbcups b21efd0
add `vesting` txs + test
reecepbcups 4341133
Merge branch 'main' into reece/complete-core
reecepbcups 609856d
cleanup / move functions to better suited files
reecepbcups 8d920bd
use `c.GetNode()` as Cosmos getFullNode
reecepbcups 60c69d0
fully test `auth`
reecepbcups 2dd180b
Use <Module>Query<Path> format (i.e. `AuthQueryAccount`)
reecepbcups 8c603c0
remove todo log
reecepbcups 8c6cb9a
rm circuit module
reecepbcups 79d8959
testStaking
reecepbcups 7e076dc
test slashing
reecepbcups 2b43cb4
deprecate `TokenFactoryGetAdmin`
reecepbcups e127b6f
cleanup `testFeeGrant`
reecepbcups eecbc6d
final self review touchups
reecepbcups 7cef1a9
cleanup `AuthPrintAccountInfo`
reecepbcups 7953959
use path.Join
reecepbcups c9a62ef
`PrefixMsgTypeIfRequired`
reecepbcups 7c9f8fd
Merge branch 'main' into reece/complete-core
reecepbcups 2544c5f
Merge branch 'main' into reece/complete-core
reecepbcups 3af2926
del[0]
reecepbcups 99c1ff2
query users delegations, iter all for `found`
reecepbcups 42d7856
supplyOf.IsGTE supply
reecepbcups 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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,7 @@ | ||
| package cosmos | ||
|
|
||
| // TODO: convert all to tn or c CosmosChain? (i think tn so we can chose the server to run it on) | ||
| // TODO: convert all queries to either <Module>GetFunc or <Module>QueryFunc | ||
|
|
||
| // TODO: | ||
| // - move anything from chain_node to its respective module |
This file contains hidden or 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,130 @@ | ||
| package cosmos | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
|
|
||
| codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
| authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
| vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" | ||
|
|
||
| cdctypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
| ) | ||
|
|
||
| func (c *CosmosChain) AuthGetAccount(ctx context.Context, addr string) (*cdctypes.Any, error) { | ||
| res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).Account(ctx, &authtypes.QueryAccountRequest{ | ||
| Address: addr, | ||
| }) | ||
| return res.Account, err | ||
| } | ||
|
|
||
| func (c *CosmosChain) AuthParams(ctx context.Context, addr string) (*authtypes.Params, error) { | ||
| res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).Params(ctx, &authtypes.QueryParamsRequest{}) | ||
| return &res.Params, err | ||
| } | ||
|
|
||
| func (c *CosmosChain) AuthModuleAccounts(ctx context.Context, addr string) ([]*cdctypes.Any, error) { | ||
| res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).ModuleAccounts(ctx, &authtypes.QueryModuleAccountsRequest{}) | ||
| return res.Accounts, err | ||
| } | ||
|
|
||
| // AuthGetModuleAccount performs a query to get the account details of the specified chain module | ||
| func (c *CosmosChain) AuthGetModuleAccount(ctx context.Context, moduleName string) (QueryModuleAccountResponse, error) { | ||
| node := c.GetNode() | ||
| stdout, _, err := node.ExecQuery(ctx, "auth", "module-account", moduleName) | ||
| if err != nil { | ||
| return QueryModuleAccountResponse{}, err | ||
| } | ||
|
|
||
| queryRes := QueryModuleAccountResponse{} | ||
| err = json.Unmarshal(stdout, &queryRes) | ||
| if err != nil { | ||
| return QueryModuleAccountResponse{}, err | ||
| } | ||
| return queryRes, nil | ||
| } | ||
|
|
||
| // GetModuleAddress performs a query to get the address of the specified chain module | ||
| func (c *CosmosChain) AuthGetModuleAddress(ctx context.Context, moduleName string) (string, error) { | ||
| queryRes, err := c.AuthGetModuleAccount(ctx, moduleName) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| return queryRes.Account.BaseAccount.Address, nil | ||
| } | ||
|
|
||
| func (c *CosmosChain) AuthBech32Prefix(ctx context.Context) (string, error) { | ||
| res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).Bech32Prefix(ctx, &authtypes.Bech32PrefixRequest{}) | ||
| return res.Bech32Prefix, err | ||
| } | ||
|
|
||
| // AddressBytesToString | ||
| func (c *CosmosChain) AuthAddressBytesToString(ctx context.Context, addrBz []byte) (string, error) { | ||
| res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).AddressBytesToString(ctx, &authtypes.AddressBytesToStringRequest{ | ||
| AddressBytes: addrBz, | ||
| }) | ||
| return res.AddressString, err | ||
| } | ||
|
|
||
| // AddressStringToBytes | ||
| func (c *CosmosChain) AuthAddressStringToBytes(ctx context.Context, addr string) ([]byte, error) { | ||
| res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).AddressStringToBytes(ctx, &authtypes.AddressStringToBytesRequest{ | ||
| AddressString: addr, | ||
| }) | ||
| return res.AddressBytes, err | ||
| } | ||
|
|
||
| // AccountInfo | ||
| func (c *CosmosChain) AuthAccountInfo(ctx context.Context, addr string) (*authtypes.BaseAccount, error) { | ||
| res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).AccountInfo(ctx, &authtypes.QueryAccountInfoRequest{ | ||
| Address: addr, | ||
| }) | ||
| return res.Info, err | ||
| } | ||
|
|
||
| func (c *CosmosChain) AuthPrintAccountInfo(chain *CosmosChain, res *codectypes.Any) error { | ||
| switch res.TypeUrl { | ||
| case "/cosmos.auth.v1beta1.ModuleAccount": | ||
| var modAcc authtypes.ModuleAccount | ||
| err := chain.GetCodec().Unmarshal(res.Value, &modAcc) | ||
| fmt.Printf("modAcc: %+v\n", modAcc) | ||
| return err | ||
|
jtieri marked this conversation as resolved.
Outdated
|
||
|
|
||
| case "/cosmos.vesting.v1beta1.VestingAccount": | ||
| var vestingAcc vestingtypes.BaseVestingAccount | ||
| err := chain.GetCodec().Unmarshal(res.Value, &vestingAcc) | ||
| fmt.Printf("BaseVestingAccount: %+v\n", vestingAcc) | ||
| return err | ||
|
|
||
| case "/cosmos.vesting.v1beta1.PeriodicVestingAccount": | ||
| var vestingAcc vestingtypes.PeriodicVestingAccount | ||
| err := chain.GetCodec().Unmarshal(res.Value, &vestingAcc) | ||
| fmt.Printf("PeriodicVestingAccount: %+v\n", vestingAcc) | ||
| return err | ||
|
|
||
| case "/cosmos.vesting.v1beta1.ContinuousVestingAccount": | ||
| var vestingAcc vestingtypes.ContinuousVestingAccount | ||
| err := chain.GetCodec().Unmarshal(res.Value, &vestingAcc) | ||
| fmt.Printf("ContinuousVestingAccount: %+v\n", vestingAcc) | ||
| return err | ||
|
|
||
| case "/cosmos.vesting.v1beta1.DelayedVestingAccount": | ||
| var vestingAcc vestingtypes.DelayedVestingAccount | ||
| err := chain.GetCodec().Unmarshal(res.Value, &vestingAcc) | ||
| fmt.Printf("DelayedVestingAccount: %+v\n", vestingAcc) | ||
| return err | ||
|
|
||
| case "/cosmos.vesting.v1beta1.PermanentLockedAccount": | ||
| var vestingAcc vestingtypes.PermanentLockedAccount | ||
| err := chain.GetCodec().Unmarshal(res.Value, &vestingAcc) | ||
| fmt.Printf("PermanentLockedAccount: %+v\n", vestingAcc) | ||
| return err | ||
|
|
||
| default: | ||
| var baseAcc authtypes.BaseAccount | ||
| err := chain.GetCodec().Unmarshal(res.Value, &baseAcc) | ||
| fmt.Printf("baseAcc: %+v\n", baseAcc) | ||
| return err | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Required for module_auth.go (converting the any types -> accounts)