Skip to content

Commit

Permalink
[SmartAccount] Get authenticator query (#8142)
Browse files Browse the repository at this point in the history
* add get_authenticator query

* stargate whitelist all current smartaccount queries

* fix fail build

* Revert "fix non-deterministic spend limit test"

This reverts commit 0c7252b.

* update changelog

* Revert "update changelog"

This reverts commit e71dc74.

* Revert "Revert "fix non-deterministic spend limit test""

This reverts commit 300d81c.

* update changelog without autoformat

* Generated protofile changes

* (fix staled gh action report) Revert "Generated protofile changes"

This reverts commit 54cdef7.

* Revert "(fix staled gh action report) Revert "Generated protofile changes""

This reverts commit fe4f535.

* fix wrong type

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
iboss-ptk and github-actions authored Apr 26, 2024
1 parent e9cd4dc commit bb3d2ed
Show file tree
Hide file tree
Showing 6 changed files with 625 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### State Compatible

* [#8142](https://github.com/osmosis-labs/osmosis/pull/8142) Add query for getting single authenticator and add stargate whitelist for the query.

## v24.0.3

* [#21](https://github.com/osmosis-labs/cometbft/pull/21) Move websocket logs to Debug
Expand Down
17 changes: 17 additions & 0 deletions proto/osmosis/smartaccount/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ service Query {
option (google.api.http).get = "/osmosis/smartaccount/params";
}

rpc GetAuthenticator(GetAuthenticatorRequest)
returns (GetAuthenticatorResponse) {
option (google.api.http).get =
"/osmosis/smartaccount/authenticator/{account}/{authenticator_id}";
}

rpc GetAuthenticators(GetAuthenticatorsRequest)
returns (GetAuthenticatorsResponse) {
option (google.api.http).get =
Expand All @@ -38,4 +44,15 @@ message GetAuthenticatorsRequest { string account = 1; }
// MsgGetAuthenticatorsResponse defines the Msg/GetAuthenticators response type.
message GetAuthenticatorsResponse {
repeated AccountAuthenticator account_authenticators = 1;
}

// MsgGetAuthenticatorRequest defines the Msg/GetAuthenticator request type.
message GetAuthenticatorRequest {
string account = 1;
uint64 authenticator_id = 2;
}

// MsgGetAuthenticatorResponse defines the Msg/GetAuthenticator response type.
message GetAuthenticatorResponse {
AccountAuthenticator account_authenticator = 1;
}
5 changes: 5 additions & 0 deletions wasmbinding/stargate_whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
minttypes "github.com/osmosis-labs/osmosis/v24/x/mint/types"
poolincentivestypes "github.com/osmosis-labs/osmosis/v24/x/pool-incentives/types"
poolmanagerqueryproto "github.com/osmosis-labs/osmosis/v24/x/poolmanager/client/queryproto"
smartaccounttypes "github.com/osmosis-labs/osmosis/v24/x/smart-account/types"
superfluidtypes "github.com/osmosis-labs/osmosis/v24/x/superfluid/types"
tokenfactorytypes "github.com/osmosis-labs/osmosis/v24/x/tokenfactory/types"
twapquerytypes "github.com/osmosis-labs/osmosis/v24/x/twap/client/queryproto"
Expand Down Expand Up @@ -139,6 +140,10 @@ func init() {
setWhitelistedQuery("/osmosis.superfluid.Query/AllAssets", &superfluidtypes.AllAssetsResponse{})
setWhitelistedQuery("/osmosis.superfluid.Query/AssetMultiplier", &superfluidtypes.AssetMultiplierResponse{})

// smartaccount
setWhitelistedQuery("/osmosis.smartaccount.v1beta1.Query/GetAuthenticator", &smartaccounttypes.GetAuthenticatorResponse{})
setWhitelistedQuery("/osmosis.smartaccount.v1beta1.Query/GetAuthenticators", &smartaccounttypes.GetAuthenticatorsResponse{})

// poolmanager
setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/NumPools", &poolmanagerqueryproto.NumPoolsResponse{})
setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/EstimateSwapExactAmountIn", &poolmanagerqueryproto.EstimateSwapExactAmountInResponse{})
Expand Down
22 changes: 22 additions & 0 deletions x/smart-account/keeper/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,25 @@ func (k Keeper) GetAuthenticators(

return &types.GetAuthenticatorsResponse{AccountAuthenticators: authenticators}, nil
}

func (k Keeper) GetAuthenticator(
ctx context.Context,
request *types.GetAuthenticatorRequest,
) (*types.GetAuthenticatorResponse, error) {
if request == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

sdkCtx := sdk.UnwrapSDKContext(ctx)
acc, err := sdk.AccAddressFromBech32(request.Account)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

authenticator, err := k.GetSelectedAuthenticatorData(sdkCtx, acc, int(request.AuthenticatorId))
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

return &types.GetAuthenticatorResponse{AccountAuthenticator: authenticator}, nil
}
Loading

0 comments on commit bb3d2ed

Please sign in to comment.