Skip to content

Commit

Permalink
Add waiting time to remove parachain token (#201)
Browse files Browse the repository at this point in the history
* param

* add app.go

* nit

* refactor proto

* add store remove list

* add abci

* correct time
  • Loading branch information
GNaD13 authored Jul 19, 2023
1 parent f422fb5 commit 8f78ea0
Show file tree
Hide file tree
Showing 28 changed files with 1,404 additions and 423 deletions.
1 change: 1 addition & 0 deletions app/ibctesting/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ func NewSimApp(
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.TransferMiddlewarekeeper = transfermiddlewarekeeper.NewKeeper(
keys[transfermiddlewaretypes.StoreKey],
app.GetSubspace(transfermiddlewaretypes.ModuleName),
appCodec,
app.IBCKeeper.ChannelKeeper,
app.TransferKeeper,
Expand Down
2 changes: 2 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(

appKeepers.TransferMiddlewareKeeper = transfermiddlewarekeeper.NewKeeper(
appKeepers.keys[transfermiddlewaretypes.StoreKey],
appKeepers.GetSubspace(transfermiddlewaretypes.ModuleName),
appCodec,
&appKeepers.HooksICS4Wrapper,
&appKeepers.TransferKeeper,
Expand Down Expand Up @@ -413,6 +414,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(alliancemoduletypes.ModuleName)
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(transfermiddlewaretypes.ModuleName)

return paramsKeeper
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ require (
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.30.0
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
Expand Down
6 changes: 3 additions & 3 deletions proto/centauri/mint/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ option go_package = "x/mint/types";
// GenesisState defines the mint module's genesis state.
message GenesisState {
// minter is a space for holding current inflation information.
Minter minter = 1 [(gogoproto.nullable) = false];
Minter minter = 1 [ (gogoproto.nullable) = false ];

// params defines all the paramaters of the module.
Params params = 2 [(gogoproto.nullable) = false];
Params params = 2 [ (gogoproto.nullable) = false ];

cosmos.base.v1beta1.Coin incentives_supply = 3 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin",
(gogoproto.nullable) = false
(gogoproto.nullable) = false
];
}
28 changes: 14 additions & 14 deletions proto/centauri/mint/v1beta1/mint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import "cosmos_proto/cosmos.proto";
message Minter {
// current annual inflation rate
string inflation = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
(gogoproto.nullable) = false
];
// current annual expected provisions
string annual_provisions = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
(gogoproto.nullable) = false
];
}

Expand All @@ -30,28 +30,28 @@ message Params {
string mint_denom = 1;
// maximum annual change in inflation rate
string inflation_rate_change = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
(gogoproto.nullable) = false
];
// goal of percent bonded atoms
string goal_bonded = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
(gogoproto.nullable) = false
];
// expected blocks per year
uint64 blocks_per_year = 4;
// expected max amount of token to be distribute per year
string max_token_per_year = 6[
(cosmos_proto.scalar) = "cosmos.Int",
string max_token_per_year = 6 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
(gogoproto.nullable) = false
];
// expected mint amount of token to be distribute per year
string min_token_per_year = 7 [
(cosmos_proto.scalar) = "cosmos.Dec",
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
(gogoproto.nullable) = false
];
}
16 changes: 11 additions & 5 deletions proto/centauri/mint/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ service Query {
}

// AnnualProvisions current minting annual provisions value.
rpc AnnualProvisions(QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) {
rpc AnnualProvisions(QueryAnnualProvisionsRequest)
returns (QueryAnnualProvisionsResponse) {
option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions";
}
}
Expand All @@ -31,7 +32,7 @@ message QueryParamsRequest {}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
Params params = 1 [ (gogoproto.nullable) = false ];
}

// QueryInflationRequest is the request type for the Query/Inflation RPC method.
Expand All @@ -41,7 +42,10 @@ message QueryInflationRequest {}
// method.
message QueryInflationResponse {
// inflation is the current minting inflation value.
bytes inflation = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
bytes inflation = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

// QueryAnnualProvisionsRequest is the request type for the
Expand All @@ -52,6 +56,8 @@ message QueryAnnualProvisionsRequest {}
// Query/AnnualProvisions RPC method.
message QueryAnnualProvisionsResponse {
// annual_provisions is the current minting annual provisions value.
bytes annual_provisions = 1
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
bytes annual_provisions = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
28 changes: 17 additions & 11 deletions proto/centauri/mint/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@ service Msg {
option (cosmos.msg.v1.service) = true;

rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
rpc FundModuleAccount(MsgFundModuleAccount) returns (MsgFundModuleAccountResponse);
rpc AddAccountToFundModuleSet(MsgAddAccountToFundModuleSet) returns (MsgAddAccountToFundModuleSetResponse);
rpc FundModuleAccount(MsgFundModuleAccount)
returns (MsgFundModuleAccountResponse);
rpc AddAccountToFundModuleSet(MsgAddAccountToFundModuleSet)
returns (MsgAddAccountToFundModuleSetResponse);
}

// MsgUpdateParams is the Msg/UpdateParams request type.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "centauri/x/mint/MsgUpdateParams";
option (amino.name) = "centauri/x/mint/MsgUpdateParams";

// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// authority is the address that controls the module (defaults to x/gov unless
// overwritten).
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// params defines the x/mint parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
Params params = 2
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// MsgUpdateParamsResponse defines the response structure for executing a
Expand All @@ -42,8 +46,8 @@ message MsgUpdateParams {
message MsgUpdateParamsResponse {}

message MsgFundModuleAccount {
string from_address = 1;
repeated cosmos.base.v1beta1.Coin amount = 2 [
string from_address = 1;
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
Expand All @@ -54,9 +58,11 @@ message MsgFundModuleAccountResponse {}

// MsgAddAccountToFundModuleSet add account in to allowed fund module set
message MsgAddAccountToFundModuleSet {
// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1[ (gogoproto.moretags) = "yaml:\"authority\"" ];
string allowed_address = 2 [ (gogoproto.moretags) = "yaml:\"allowed_address\"" ];
// authority is the address that controls the module (defaults to x/gov unless
// overwritten).
string authority = 1 [ (gogoproto.moretags) = "yaml:\"authority\"" ];
string allowed_address = 2
[ (gogoproto.moretags) = "yaml:\"allowed_address\"" ];
}

message MsgAddAccountToFundModuleSetResponse {}
18 changes: 5 additions & 13 deletions proto/centauri/transfermiddleware/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,15 @@ syntax = "proto3";
package centauri.transfermiddleware.v1beta1;

import "gogoproto/gogo.proto";
import "centauri/transfermiddleware/v1beta1/params.proto";
import "centauri/transfermiddleware/v1beta1/parachain_token_info.proto";

option go_package = "x/transfermiddleware/types";

// GenesisState defines the module various parameters when first
// initialized
message GenesisState {
repeated ParachainIBCTokenInfo token_infos = 1 [ (gogoproto.nullable) = false ];
repeated ParachainIBCTokenInfo token_infos = 1
[ (gogoproto.nullable) = false ];
Params params = 2 [ (gogoproto.nullable) = false ];
}

// ParachainIBCTokenInfo represents information about transferable IBC tokens from Parachain.
message ParachainIBCTokenInfo{
// ibc_denom is the denomination of the ibced token transferred from the dotsama chain.
string ibc_denom = 1 [ (gogoproto.moretags) = "yaml:\"ibc_denom\"" ];
// channel_id is source channel in IBC connection from centauri chain
string channel_id = 2 [ (gogoproto.moretags) = "yaml:\"channel_id\"" ];
// native denom is new native minted denom in centauri chain.
string native_denom = 3 [ (gogoproto.moretags) = "yaml:\"native_denom\"" ];
// asset id is the id of the asset on Picasso
string asset_id = 4 [ (gogoproto.moretags) = "yaml:\"asset_id\"" ];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
syntax = "proto3";
package centauri.transfermiddleware.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";

option go_package = "x/transfermiddleware/types";

// ParachainIBCTokenInfo represents information about transferable IBC tokens
// from Parachain.
message ParachainIBCTokenInfo {
// ibc_denom is the denomination of the ibced token transferred from the
// dotsama chain.
string ibc_denom = 1 [ (gogoproto.moretags) = "yaml:\"ibc_denom\"" ];
// channel_id is source channel in IBC connection from centauri chain
string channel_id = 2 [ (gogoproto.moretags) = "yaml:\"channel_id\"" ];
// native denom is new native minted denom in centauri chain.
string native_denom = 3 [ (gogoproto.moretags) = "yaml:\"native_denom\"" ];
// asset id is the id of the asset on Picasso
string asset_id = 4 [ (gogoproto.moretags) = "yaml:\"asset_id\"" ];
}

message RemoveParachainIBCTokenInfo {
// native denom is new native minted denom in centauri chain.
string native_denom = 1 [ (gogoproto.moretags) = "yaml:\"native_denom\"" ];
//
// remove_time is the time at which the parachain token info will be removed.
google.protobuf.Timestamp remove_time = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"start_time\""
];
}
17 changes: 17 additions & 0 deletions proto/centauri/transfermiddleware/v1beta1/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";
package centauri.transfermiddleware.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";

option go_package = "x/transfermiddleware/types";

// Params holds parameters for the mint module.
message Params {
google.protobuf.Duration duration = 1 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"duration\""
];
}
31 changes: 18 additions & 13 deletions proto/centauri/transfermiddleware/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,38 @@ option go_package = "x/transfermiddleware/types";
// Query provides defines the gRPC querier service.
service Query {
// ParaTokenInfo queries all token info of a native denom.
rpc ParaTokenInfo(QueryParaTokenInfoRequest) returns (QueryParaTokenInfoResponse) {
rpc ParaTokenInfo(QueryParaTokenInfoRequest)
returns (QueryParaTokenInfoResponse) {
option (google.api.http).get = "/centauri/paratokeninfo";
}
rpc EscrowAddress(QueryEscrowAddressRequest) returns (QueryEscrowAddressResponse) {
rpc EscrowAddress(QueryEscrowAddressRequest)
returns (QueryEscrowAddressResponse) {
option (google.api.http).get = "/centauri/escrowaddress";
}
}

// message QueryEscrowAddressRequest
// message QueryEscrowAddressRequest
message QueryEscrowAddressRequest {
string channel_id = 1 [(gogoproto.moretags) = "yaml:\"channel_id\""];
string channel_id = 1 [ (gogoproto.moretags) = "yaml:\"channel_id\"" ];
}

// QueryEscrowAddressResponse
// QueryEscrowAddressResponse
message QueryEscrowAddressResponse {
string escrow_address = 1 [(gogoproto.moretags) = "yaml:\"escrow_address\""];
string escrow_address = 1
[ (gogoproto.moretags) = "yaml:\"escrow_address\"" ];
}

// QueryParaTokenInfoRequest is the request type for the Query/Params RPC method.
// QueryParaTokenInfoRequest is the request type for the Query/Params RPC
// method.
message QueryParaTokenInfoRequest {
string native_denom = 1 [(gogoproto.moretags) = "yaml:\"native_denom\""];
string native_denom = 1 [ (gogoproto.moretags) = "yaml:\"native_denom\"" ];
}

// QueryParaTokenInfoResponse is the response type for the Query/ParaTokenInfo RPC method.
// QueryParaTokenInfoResponse is the response type for the Query/ParaTokenInfo
// RPC method.
message QueryParaTokenInfoResponse {
string ibc_denom = 1 [ (gogoproto.moretags) = "yaml:\"ibc_denom\"" ];
string channel_id = 2 [ (gogoproto.moretags) = "yaml:\"channel_id\"" ];
string native_denom = 3 [ (gogoproto.moretags) = "yaml:\"native_denom\"" ];
string asset_id = 4 [ (gogoproto.moretags) = "yaml:\"asset_id\"" ];
string ibc_denom = 1 [ (gogoproto.moretags) = "yaml:\"ibc_denom\"" ];
string channel_id = 2 [ (gogoproto.moretags) = "yaml:\"channel_id\"" ];
string native_denom = 3 [ (gogoproto.moretags) = "yaml:\"native_denom\"" ];
string asset_id = 4 [ (gogoproto.moretags) = "yaml:\"asset_id\"" ];
}
Loading

0 comments on commit 8f78ea0

Please sign in to comment.