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

feat: Impl basic module and keeper methods #174

Merged
merged 20 commits into from
Aug 22, 2024
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
5 changes: 1 addition & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,17 +407,14 @@ func New(
// realio keeper
app.AssetKeeper = *assetmodulekeeper.NewKeeper(
appCodec,
app.interfaceRegistry,
keys[assetmoduletypes.StoreKey],
keys[assetmoduletypes.MemStoreKey],
app.GetSubspace(assetmoduletypes.ModuleName),
app.BankKeeper,
app.AccountKeeper,
app.ModuleAccountAddrs(),
)

// Add transfer restriction
app.BankKeeper.AppendSendRestriction(app.AssetKeeper.AssetSendRestriction)

// IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,
Expand Down
2 changes: 2 additions & 0 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func Setup(
panic(err)
}
genesisState[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis)
} else {
genesisState[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarkettypes.DefaultGenesisState())
}

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ require (
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/rjeczalik/notify v0.9.3 // indirect
github.com/rs/cors v1.8.3 // indirect
github.com/rs/zerolog v1.27.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
Expand Down
4 changes: 3 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,9 @@ github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE=
github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho=
github.com/rjeczalik/notify v0.9.3 h1:6rJAzHTGKXGj76sbRgDiDcYj/HniypXmSJo1SWakZeY=
github.com/rjeczalik/notify v0.9.3/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down Expand Up @@ -1402,6 +1403,7 @@ golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
2 changes: 1 addition & 1 deletion proto/buf.gen.gogo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: v1
plugins:
- name: gocosmos
out: .
opt: plugins=grpc
opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types
- name: grpc-gateway
out: .
opt: logtostderr=true,allow_colon_final_segments=true
18 changes: 0 additions & 18 deletions proto/realionetwork/asset/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ service Query {
rpc Token(QueryTokenRequest) returns (QueryTokenResponse) {
option (google.api.http).get = "/realionetwork/asset/v1/tokens/{symbol}";
}

// Parameters queries the tokens of the module.
rpc IsAuthorized(QueryIsAuthorizedRequest) returns (QueryIsAuthorizedResponse) {
option (google.api.http).get = "/realionetwork/asset/v1/isauthorized/{symbol}/{address}";
}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
Expand Down Expand Up @@ -60,16 +55,3 @@ message QueryTokenResponse {
// params holds all the parameters of this module.
Token token = 1 [ (gogoproto.nullable) = false ];
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryIsAuthorizedRequest {
// symbol is the token symbol to query for.
string symbol = 1;
string address = 2;
}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryIsAuthorizedResponse {
// params holds all the parameters of this module.
bool isAuthorized = 1;
}
12 changes: 12 additions & 0 deletions proto/realionetwork/asset/v1/test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package realionetwork.asset.v1;

option go_package = "github.com/realiotech/realio-network/x/asset/types";

message MsgMock {
uint64 count = 1;
}

message MsgMockResponse {
uint64 count = 1;
}
22 changes: 16 additions & 6 deletions proto/realionetwork/asset/v1/token.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@ option go_package = "github.com/realiotech/realio-network/x/asset/types";

// Token represents an asset in the module
message Token {
option (gogoproto.equal) = false;
option (gogoproto.equal) = false;

string name = 1;
string symbol = 2;
string decimal = 3;
string description = 4;
string token_id = 1;
string name = 2;
string symbol = 3;
uint32 decimal = 4;
string description = 5;
}

message TokenManagement {
string manager = 1[(cosmos_proto.scalar) = "cosmos.AddressString"];
string manager = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
bool add_new_privilege = 2;
repeated string excluded_privileges = 3;
}

message Balance {
string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
uint64 amount = 2;
}

message PrivilegeList {
repeated string privileges = 1;
}
27 changes: 19 additions & 8 deletions proto/realionetwork/asset/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ option go_package = "github.com/realiotech/realio-network/x/asset/types";

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/bank/v1beta1/genesis.proto";
import "google/protobuf/any.proto";
import "realionetwork/asset/v1/token.proto";

// Msg defines the Msg service.
service Msg {

rpc CreateToken(MsgCreateToken) returns (MsgCreateTokenResponse);
rpc UpdateToken(MsgUpdateToken) returns (MsgUpdateTokenResponse);
rpc AllocateToken(MsgAllocateToken) returns (MsgAllocateTokenResponse);
rpc AssignPrivilege(MsgAssignPrivilege) returns (MsgAssignPrivilegeResponse);
rpc UnassignPrivilege(MsgUnassignPrivilege)
Expand All @@ -27,19 +27,30 @@ message MsgCreateToken {
string manager = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string name = 3;
string symbol = 4;
string decimal = 5;
repeated string excluded_privileges = 6;
bool add_new_privilege = 7;
uint32 decimal = 5;
string description = 6;
repeated string excluded_privileges = 7;
bool add_new_privilege = 8;
}

message MsgCreateTokenResponse {}

message MsgUpdateToken {
string manager = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string token_id = 2;
string name = 3;
string symbol = 4;
string description = 5;
bool add_new_privilege = 6;
}

message MsgUpdateTokenResponse {}

message MsgAllocateToken {
string manager = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string token_id = 2;
repeated cosmos.bank.v1beta1.Balance balances = 3
repeated Balance balances = 3
[ (gogoproto.nullable) = false ];
repeated google.protobuf.Any vesting_balance = 4;
}

message MsgAllocateTokenResponse {}
Expand Down Expand Up @@ -75,7 +86,7 @@ message MsgDisablePrivilegeResponse {}
message MsgExecutePrivilege {
string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string token_id = 2;
google.protobuf.Any privilege_msg = 3;
google.protobuf.Any privilege_msg = 3 [(cosmos_proto.accepts_interface) = "realionetwork.asset.v1.PrivilegeI"];;
}

message MsgExecutePrivilegeResponse {}
8 changes: 2 additions & 6 deletions testutil/network/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,8 @@ func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalance
cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[assettypes.ModuleName], &assetGenState)

assetGenState.Tokens = append(assetGenState.Tokens, assettypes.Token{
Manager: genAccounts[0].GetAddress().String(),
Name: "Realio Security Token",
Symbol: "RST",
Total: "50000000",
AuthorizationRequired: true,
Authorized: []*assettypes.TokenAuthorization{{Address: genAccounts[0].GetAddress().String(), Authorized: true}},
Name: "Realio Security Token",
Symbol: "RST",
})
cfg.GenesisState[assettypes.ModuleName] = cfg.Codec.MustMarshalJSON(&assetGenState)

Expand Down
8 changes: 1 addition & 7 deletions x/asset/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ func GetTxCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

cmd.AddCommand(CmdMsgCreateToken())
cmd.AddCommand(CmdMsgUpdateToken())
cmd.AddCommand(CmdCreateToken())
cmd.AddCommand(CmdUpdateToken())
cmd.AddCommand(CmdAuthorizeAddress())
cmd.AddCommand(CmdUnAuthorizeAddress())
cmd.AddCommand(CmdTransferToken())

// this line is used by starport scaffolding # 1

return cmd
Expand Down
44 changes: 0 additions & 44 deletions x/asset/client/cli/tx_authorize_address.go

This file was deleted.

53 changes: 0 additions & 53 deletions x/asset/client/cli/tx_create_token.go

This file was deleted.

53 changes: 0 additions & 53 deletions x/asset/client/cli/tx_msg_create_token.go

This file was deleted.

Loading