Skip to content
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

Add amino proto annotations #4629

Merged
merged 10 commits into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#4659](https://github.com/osmosis-labs/osmosis/pull/4659) implement AllPools query in x/poolmanager.
* [#4783](https://github.com/osmosis-labs/osmosis/pull/4783) Update wasmd to 0.31.0
* [#4629](https://github.com/osmosis-labs/osmosis/pull/4629) add amino proto annotations
* [#4830](https://github.com/osmosis-labs/osmosis/pull/4830) Add gas cost when we AddToGaugeRewards, linearly increase with coins to add
* [#4886](https://github.com/osmosis-labs/osmosis/pull/4886) Implement MsgSplitRouteSwapExactAmountIn and MsgSplitRouteSwapExactAmountOut that supports route splitting.
* [#5000](https://github.com/osmosis-labs/osmosis/pull/5000) osmomath.Power panics for base < 1 to temporarily restrict broken logic for such base.
Expand Down
77 changes: 77 additions & 0 deletions proto/amino/amino.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
syntax = "proto3";

package amino;

import "google/protobuf/descriptor.proto";

option go_package = "github.com/cosmos/cosmos-sdk/types/tx/amino";

extend google.protobuf.MessageOptions {
// name is the string used when registering a concrete
// type into the Amino type registry, via the Amino codec's
// `RegisterConcrete()` method. This string MUST be at most 39
// characters long, or else the message will be rejected by the
// Ledger hardware device.
string name = 11110001;

// encoding describes the encoding format used by Amino for the given
// message. The field type is chosen to be a string for
// flexibility, but it should ideally be short and expected to be
// machine-readable, for example "base64" or "utf8_json". We
// highly recommend to use underscores for word separation instead of spaces.
//
// If left empty, then the Amino encoding is expected to be the same as the
// Protobuf one.
//
// This annotation should not be confused with the `encoding`
// one which operates on the field level.
string message_encoding = 11110002;
}

extend google.protobuf.FieldOptions {
// encoding describes the encoding format used by Amino for
// the given field. The field type is chosen to be a string for
// flexibility, but it should ideally be short and expected to be
// machine-readable, for example "base64" or "utf8_json". We
// highly recommend to use underscores for word separation instead of spaces.
//
// If left empty, then the Amino encoding is expected to be the same as the
// Protobuf one.
//
// This annotation should not be confused with the
// `message_encoding` one which operates on the message level.
string encoding = 11110003;

// field_name sets a different field name (i.e. key name) in
// the amino JSON object for the given field.
//
// Example:
//
// message Foo {
// string bar = 1 [(amino.field_name) = "baz"];
// }
//
// Then the Amino encoding of Foo will be:
// `{"baz":"some value"}`
string field_name = 11110004;

// dont_omitempty sets the field in the JSON object even if
// its value is empty, i.e. equal to the Golang zero value. To learn what
// the zero values are, see https://go.dev/ref/spec#The_zero_value.
//
// Fields default to `omitempty`, which is the default behavior when this
// annotation is unset. When set to true, then the field value in the
// JSON object will be set, i.e. not `undefined`.
//
// Example:
//
// message Foo {
// string bar = 1;
// string baz = 2 [(amino.dont_omitempty) = true];
// }
//
// f := Foo{};
// out := AminoJSONEncoder(&f);
// out == {"baz":""}
bool dont_omitempty = 11110005;
}
4 changes: 4 additions & 0 deletions proto/osmosis/gamm/pool-models/balancer/balancerPool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package osmosis.gamm.v1beta1;

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "amino/amino.proto";

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
Expand Down Expand Up @@ -74,6 +75,8 @@ message SmoothWeightChangeParams {
// governance. Instead they will be managed by the token holders of the pool.
// The pool's token holders are specified in future_pool_governor.
message PoolParams {
option (amino.name) = "osmosis/gamm/BalancerPoolParams";

string swap_fee = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"swap_fee\"",
Expand Down Expand Up @@ -114,6 +117,7 @@ message Pool {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (cosmos_proto.implements_interface) = "PoolI";
option (amino.name) = "osmosis/gamm/BalancerPool";

string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
uint64 id = 2;
Expand Down
3 changes: 3 additions & 0 deletions proto/osmosis/gamm/pool-models/balancer/tx/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package osmosis.gamm.poolmodels.balancer.v1beta1;

import "gogoproto/gogo.proto";
import "amino/amino.proto";
import "osmosis/gamm/pool-models/balancer/balancerPool.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/timestamp.proto";
Expand All @@ -18,6 +19,8 @@ service Msg {

// ===================== MsgCreatePool
message MsgCreateBalancerPool {
option (amino.name) = "osmosis/gamm/create-balancer-pool";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];

osmosis.gamm.v1beta1.PoolParams pool_params = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package osmosis.gamm.poolmodels.stableswap.v1beta1;

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "amino/amino.proto";

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
Expand All @@ -17,6 +18,8 @@ option go_package = "github.com/osmosis-labs/osmosis/v15/x/gamm/pool-models/stab
// governance. Instead they will be managed by the token holders of the pool.
// The pool's token holders are specified in future_pool_governor.
message PoolParams {
option (amino.name) = "osmosis/gamm/StableswapPoolParams";

string swap_fee = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"swap_fee\"",
Expand All @@ -37,6 +40,7 @@ message Pool {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (cosmos_proto.implements_interface) = "PoolI";
option (amino.name) = "osmosis/gamm/StableswapPool";

string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
uint64 id = 2;
Expand Down
5 changes: 5 additions & 0 deletions proto/osmosis/gamm/pool-models/stableswap/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package osmosis.gamm.poolmodels.stableswap.v1beta1;

import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "amino/amino.proto";
import "osmosis/gamm/pool-models/stableswap/stableswap_pool.proto";

option go_package = "github.com/osmosis-labs/osmosis/v15/x/gamm/pool-models/stableswap";
Expand All @@ -16,6 +17,8 @@ service Msg {

// ===================== MsgCreatePool
message MsgCreateStableswapPool {
option (amino.name) = "osmosis/gamm/create-stableswap-pool";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];

PoolParams pool_params = 2 [ (gogoproto.moretags) = "yaml:\"pool_params\"" ];
Expand Down Expand Up @@ -43,6 +46,8 @@ message MsgCreateStableswapPoolResponse {
// Sender must be the pool's scaling_factor_governor in order for the tx to
// succeed. Adjusts stableswap scaling factors.
message MsgStableSwapAdjustScalingFactors {
option (amino.name) = "osmosis/gamm/stableswap-adjust-scaling-factors";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
uint64 pool_id = 2 [ (gogoproto.customname) = "PoolID" ];

Expand Down
6 changes: 6 additions & 0 deletions proto/osmosis/gamm/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package osmosis.gamm.v1beta1;

import "gogoproto/gogo.proto";
import "osmosis/gamm/v1beta1/genesis.proto";
import "cosmos_proto/cosmos.proto";
import "amino/amino.proto";

option go_package = "github.com/osmosis-labs/osmosis/v15/x/gamm/types";

Expand All @@ -15,6 +17,8 @@ message ReplaceMigrationRecordsProposal {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (amino.name) = "osmosis/ReplaceMigrationRecordsProposal";
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";

string title = 1;
string description = 2;
Expand Down Expand Up @@ -45,6 +49,8 @@ message UpdateMigrationRecordsProposal {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (amino.name) = "osmosis/UpdateMigrationRecordsProposal";
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";

string title = 1;
string description = 2;
Expand Down
17 changes: 17 additions & 0 deletions proto/osmosis/gamm/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package osmosis.gamm.v1beta1;

import "gogoproto/gogo.proto";
import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "osmosis/poolmanager/v1beta1/swap_route.proto";

Expand All @@ -27,6 +28,8 @@ service Msg {
// ===================== MsgJoinPool
// This is really MsgJoinPoolNoSwap
message MsgJoinPool {
option (amino.name) = "osmosis/gamm/join-pool";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string share_out_amount = 3 [
Expand Down Expand Up @@ -54,6 +57,8 @@ message MsgJoinPoolResponse {

// ===================== MsgExitPool
message MsgExitPool {
option (amino.name) = "osmosis/gamm/exit-pool";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string share_in_amount = 3 [
Expand All @@ -77,6 +82,8 @@ message MsgExitPoolResponse {

// ===================== MsgSwapExactAmountIn
message MsgSwapExactAmountIn {
option (amino.name) = "osmosis/gamm/exit-pool";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
repeated osmosis.poolmanager.v1beta1.SwapAmountInRoute routes = 2
[ (gogoproto.nullable) = false ];
Expand All @@ -100,6 +107,8 @@ message MsgSwapExactAmountInResponse {
}

message MsgSwapExactAmountOut {
option (amino.name) = "osmosis/gamm/swap-exact-amount-out";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
repeated osmosis.poolmanager.v1beta1.SwapAmountOutRoute routes = 2
[ (gogoproto.nullable) = false ];
Expand All @@ -125,6 +134,8 @@ message MsgSwapExactAmountOutResponse {
// ===================== MsgJoinSwapExternAmountIn
// TODO: Rename to MsgJoinSwapExactAmountIn
message MsgJoinSwapExternAmountIn {
option (amino.name) = "osmosis/gamm/join-swap-extern-amount-in";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
cosmos.base.v1beta1.Coin token_in = 3 [
Expand Down Expand Up @@ -152,6 +163,8 @@ message MsgJoinSwapExternAmountInResponse {

// ===================== MsgJoinSwapShareAmountOut
message MsgJoinSwapShareAmountOut {
option (amino.name) = "osmosis/gamm/join-swap-share-amount-out";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string token_in_denom = 3
Expand All @@ -178,6 +191,8 @@ message MsgJoinSwapShareAmountOutResponse {

// ===================== MsgExitSwapShareAmountIn
message MsgExitSwapShareAmountIn {
option (amino.name) = "osmosis/gamm/exit-swap-share-amount-in";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string token_out_denom = 3
Expand All @@ -204,6 +219,8 @@ message MsgExitSwapShareAmountInResponse {

// ===================== MsgExitSwapExternAmountOut
message MsgExitSwapExternAmountOut {
option (amino.name) = "osmosis/gamm/exit-swap-extern-amount-out";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
cosmos.base.v1beta1.Coin token_out = 3 [
Expand Down
5 changes: 5 additions & 0 deletions proto/osmosis/incentives/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package osmosis.incentives;

import "gogoproto/gogo.proto";
import "amino/amino.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";
import "osmosis/incentives/gauge.proto";
Expand All @@ -16,6 +17,8 @@ service Msg {

// MsgCreateGauge creates a gague to distribute rewards to users
message MsgCreateGauge {
option (amino.name) = "osmosis/incentives/create-gauge";

// is_perpetual shows if it's a perpetual or non-perpetual gauge
// Non-perpetual gauges distribute their tokens equally per epoch while the
// gauge is in the active period. Perpetual gauges distribute all their tokens
Expand Down Expand Up @@ -47,6 +50,8 @@ message MsgCreateGaugeResponse {}

// MsgAddToGauge adds coins to a previously created gauge
message MsgAddToGauge {
option (amino.name) = "osmosis/incentives/add-to-gauge";

// owner is the gauge owner's address
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
// gauge_id is the ID of gauge that rewards are getting added to
Expand Down
7 changes: 7 additions & 0 deletions proto/osmosis/lockup/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package osmosis.lockup;

import "gogoproto/gogo.proto";
import "amino/amino.proto";
import "google/protobuf/duration.proto";
import "cosmos/base/v1beta1/coin.proto";
import "osmosis/lockup/lock.proto";
Expand All @@ -23,6 +24,8 @@ service Msg {
}

message MsgLockTokens {
option (amino.name) = "osmosis/lockup/lock-tokens";

string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
google.protobuf.Duration duration = 2 [
(gogoproto.nullable) = false,
Expand All @@ -38,11 +41,15 @@ message MsgLockTokens {
message MsgLockTokensResponse { uint64 ID = 1; }

message MsgBeginUnlockingAll {
option (amino.name) = "osmosis/lockup/begin-unlock-tokens";

string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
}
message MsgBeginUnlockingAllResponse { repeated PeriodLock unlocks = 1; }

message MsgBeginUnlocking {
option (amino.name) = "osmosis/lockup/begin-unlock-period-lock";

string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
uint64 ID = 2;
// Amount of unlocking coins. Unlock all if not set.
Expand Down
6 changes: 6 additions & 0 deletions proto/osmosis/pool-incentives/v1beta1/gov.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
syntax = "proto3";
package osmosis.poolincentives.v1beta1;

import "cosmos_proto/cosmos.proto";
import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "osmosis/pool-incentives/v1beta1/incentives.proto";

Expand All @@ -17,6 +19,8 @@ message ReplacePoolIncentivesProposal {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (amino.name) = "osmosis/ReplacePoolIncentivesProposal";
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";

string title = 1;
string description = 2;
Expand All @@ -42,6 +46,8 @@ message UpdatePoolIncentivesProposal {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (amino.name) = "osmosis/UpdatePoolIncentivesProposal";
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";

string title = 1;
string description = 2;
Expand Down
Loading