Skip to content

Commit

Permalink
added cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed Sep 8, 2024
1 parent 70a02cb commit d2c793b
Show file tree
Hide file tree
Showing 13 changed files with 750 additions and 468 deletions.
79 changes: 37 additions & 42 deletions proto/dymensionxyz/dymension/iro/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,33 @@ service Query {

// Plan returns the plan for the specified plan ID.
rpc QueryPlan(QueryPlanRequest) returns (QueryPlanResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/iro/plans/{plan_id}";
option (google.api.http).get =
"/dymensionxyz/dymension/iro/plans/{plan_id}";
}

// PlanByRollapp returns the plans for the specified rollapp ID.
rpc QueryPlanByRollapp(QueryPlanByRollappRequest) returns (QueryPlanByRollappResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/iro/plans_by_rollapp/{rollapp_id}";
rpc QueryPlanByRollapp(QueryPlanByRollappRequest)
returns (QueryPlanByRollappResponse) {
option (google.api.http).get =
"/dymensionxyz/dymension/iro/plans_by_rollapp/{rollapp_id}";
}

// Price returns the current price for 1 IRO token for the specified plan ID.
rpc QueryPrice(QueryPriceRequest) returns (QueryPriceResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/iro/price/{plan_id}";
option (google.api.http).get =
"/dymensionxyz/dymension/iro/price/{plan_id}";
}

// Cost returns the expected cost for buying or selling the specified amount of shares.
// Cost returns the expected cost for buying or selling the specified amount
// of shares.
rpc QueryCost(QueryCostRequest) returns (QueryCostResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/iro/cost/{plan_id}";
}


// Claimed returns the claimed amount thus far for the specified plan ID.
rpc QueryClaimed(QueryClaimedRequest) returns (QueryClaimedResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/iro/claimed/{plan_id}";
option (google.api.http).get =
"/dymensionxyz/dymension/iro/claimed/{plan_id}";
}
}

Expand All @@ -54,67 +59,57 @@ message QueryParamsRequest {}
// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
Params params = 1 [ (gogoproto.nullable) = false ];
}


// QueryPlanRequest is the request type for the Query/QueryPlan RPC method.
message QueryPlansRequest {
}
message QueryPlansRequest {}

// QueryPlanResponse is the response type for the Query/QueryPlan RPC method.
message QueryPlansResponse {
repeated Plan plans = 1 [(gogoproto.nullable) = false];
repeated Plan plans = 1 [ (gogoproto.nullable) = false ];
}

// QueryPlanRequest is the request type for the Query/QueryPlan RPC method.
message QueryPlanRequest {
string plan_id = 1;
}
message QueryPlanRequest { string plan_id = 1; }

// QueryPlanResponse is the response type for the Query/QueryPlan RPC method.
message QueryPlanResponse {
Plan plan = 1;
}
message QueryPlanResponse { Plan plan = 1; }

// QueryPlanByRollappRequest is the request type for the Query/QueryPlanByRollapp RPC method.
message QueryPlanByRollappRequest {
string rollapp_id = 1;
}
// QueryPlanByRollappRequest is the request type for the
// Query/QueryPlanByRollapp RPC method.
message QueryPlanByRollappRequest { string rollapp_id = 1; }

// QueryPlanByRollappResponse is the response type for the Query/QueryPlanByRollapp RPC method.
message QueryPlanByRollappResponse {
Plan plan = 1;
}
// QueryPlanByRollappResponse is the response type for the
// Query/QueryPlanByRollapp RPC method.
message QueryPlanByRollappResponse { Plan plan = 1; }

// QueryPriceRequest is the request type for the Query/QueryPrice RPC method.
message QueryPriceRequest {
string plan_id = 1;
}
message QueryPriceRequest { string plan_id = 1; }

// QueryPriceResponse is the response type for the Query/QueryPrice RPC method.
message QueryPriceResponse {
cosmos.base.v1beta1.Coin price = 1;
}
message QueryPriceResponse { cosmos.base.v1beta1.Coin price = 1; }

// QueryCostRequest is the request type for the Query/QueryCost RPC method.
message QueryCostRequest {
string plan_id = 1;
cosmos.base.v1beta1.Coin amt = 2;
string amt = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
bool sell = 3;
}

// QueryCostResponse is the response type for the Query/QueryCost RPC method.
message QueryCostResponse {
cosmos.base.v1beta1.Coin cost = 1;
}
message QueryCostResponse { cosmos.base.v1beta1.Coin cost = 1; }

// QueryClaimedRequest is the request type for the Query/QueryClaimed RPC method.
message QueryClaimedRequest {
string plan_id = 1;
}
// QueryClaimedRequest is the request type for the Query/QueryClaimed RPC
// method.
message QueryClaimedRequest { string plan_id = 1; }

// QueryClaimedResponse is the response type for the Query/QueryClaimed RPC method.
// QueryClaimedResponse is the response type for the Query/QueryClaimed RPC
// method.
message QueryClaimedResponse {
string claimed_amt = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"];
string claimed_amt = 1
[ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" ];
}
20 changes: 16 additions & 4 deletions proto/dymensionxyz/dymension/iro/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,16 @@ message MsgBuy {
string plan_id = 2;

// The amount of tokens to buy.
cosmos.base.v1beta1.Coin amount = 3;
string amount = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];

// The expected output amount.
cosmos.base.v1beta1.Coin expected_out_amount = 4;
string expected_out_amount = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

message MsgBuyResponse {}
Expand All @@ -106,10 +112,16 @@ message MsgSell {
string plan_id = 2;

// The amount of tokens to sell.
cosmos.base.v1beta1.Coin amount = 3;
string amount = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];

// The expected output amount.
cosmos.base.v1beta1.Coin expected_out_amount = 4;
string expected_out_amount = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

message MsgSellResponse {}
Expand Down
10 changes: 9 additions & 1 deletion x/iro/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ func TestGetTxCmd(t *testing.T) {

cmd = cli.CmdCreateIRO()
assert.NotNil(t, cmd)
assert.True(t, strings.HasPrefix(cmd.Use, "create-iro"))
assert.True(t, strings.HasPrefix(cmd.Use, "create"))
assert.True(t, cmd.Flags().HasFlags())

cmd = cli.CmdBuy()
assert.NotNil(t, cmd)
assert.True(t, strings.HasPrefix(cmd.Use, "buy"))

cmd = cli.CmdSell()
assert.NotNil(t, cmd)
assert.True(t, strings.HasPrefix(cmd.Use, "sell"))
}

func TestCmdCreateIRO(t *testing.T) {
Expand Down
Loading

0 comments on commit d2c793b

Please sign in to comment.