Skip to content

Commit 31c96a3

Browse files
Yurist-85kioqq
andauthored
feat: add transfer ownership feature to dao module (#329)
* feat: add transfer ownership feature to doa module * test: add tests for transfer ownership feature * chore: rename dao module to ucdao * chore: bump version in Makefile * fix: upgrade handler --------- Co-authored-by: Evgeniy Abramov <[email protected]>
1 parent 6c2cce7 commit 31c96a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1276
-369
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DIFF_TAG=$(shell git rev-list --tags="v*" --max-count=1 --not $(shell git rev-li
66
DEFAULT_TAG=$(shell git rev-list --tags="v*" --max-count=1)
77
# VERSION ?= $(shell echo $(shell git describe --tags $(or $(DIFF_TAG), $(DEFAULT_TAG))) | sed 's/^v//')
88

9-
VERSION := "1.7.6"
9+
VERSION := "1.7.7"
1010
CBFTVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
1111
COMMIT := $(shell git log -1 --format='%H')
1212
LEDGER_ENABLED ?= true

app/app.go

+31-15
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ import (
143143
"github.com/haqq-network/haqq/x/coinomics"
144144
coinomicskeeper "github.com/haqq-network/haqq/x/coinomics/keeper"
145145
coinomicstypes "github.com/haqq-network/haqq/x/coinomics/types"
146-
"github.com/haqq-network/haqq/x/dao"
147-
daokeeper "github.com/haqq-network/haqq/x/dao/keeper"
148-
daotypes "github.com/haqq-network/haqq/x/dao/types"
149146
"github.com/haqq-network/haqq/x/epochs"
150147
epochskeeper "github.com/haqq-network/haqq/x/epochs/keeper"
151148
epochstypes "github.com/haqq-network/haqq/x/epochs/types"
@@ -156,6 +153,9 @@ import (
156153
"github.com/haqq-network/haqq/x/liquidvesting"
157154
liquidvestingkeeper "github.com/haqq-network/haqq/x/liquidvesting/keeper"
158155
liquidvestingtypes "github.com/haqq-network/haqq/x/liquidvesting/types"
156+
"github.com/haqq-network/haqq/x/ucdao"
157+
ucdaokeeper "github.com/haqq-network/haqq/x/ucdao/keeper"
158+
ucdaotypes "github.com/haqq-network/haqq/x/ucdao/types"
159159
"github.com/haqq-network/haqq/x/vesting"
160160
vestingkeeper "github.com/haqq-network/haqq/x/vesting/keeper"
161161
vestingtypes "github.com/haqq-network/haqq/x/vesting/types"
@@ -172,6 +172,7 @@ import (
172172
v174 "github.com/haqq-network/haqq/app/upgrades/v1.7.4"
173173
v175 "github.com/haqq-network/haqq/app/upgrades/v1.7.5"
174174
v176 "github.com/haqq-network/haqq/app/upgrades/v1.7.6"
175+
v177 "github.com/haqq-network/haqq/app/upgrades/v1.7.7"
175176

176177
// NOTE: override ICS20 keeper to support IBC transfers of ERC20 tokens
177178
"github.com/haqq-network/haqq/x/ibc/transfer"
@@ -249,7 +250,7 @@ var (
249250
epochs.AppModuleBasic{},
250251
consensus.AppModuleBasic{},
251252
liquidvesting.AppModuleBasic{},
252-
dao.AppModuleBasic{},
253+
ucdao.AppModuleBasic{},
253254
)
254255

255256
// module account permissions
@@ -266,7 +267,7 @@ var (
266267
coinomicstypes.ModuleName: {authtypes.Minter},
267268
vestingtypes.ModuleName: nil, // Add vesting module account
268269
liquidvestingtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
269-
daotypes.ModuleName: nil,
270+
ucdaotypes.ModuleName: nil,
270271
}
271272

272273
// module accounts that are allowed to receive tokens
@@ -335,7 +336,7 @@ type Haqq struct {
335336

336337
// Haqq keepers
337338
CoinomicsKeeper coinomicskeeper.Keeper
338-
DaoKeeper daokeeper.Keeper
339+
DaoKeeper ucdaokeeper.Keeper
339340

340341
// the module manager
341342
mm *module.Manager
@@ -409,7 +410,7 @@ func NewHaqq(
409410
// haqq keys
410411
coinomicstypes.StoreKey,
411412
liquidvestingtypes.StoreKey,
412-
daotypes.StoreKey,
413+
ucdaotypes.StoreKey,
413414
)
414415

415416
// Add the EVM transient store key
@@ -559,8 +560,8 @@ func NewHaqq(
559560
app.AccountKeeper, app.BankKeeper, app.Erc20Keeper, app.VestingKeeper,
560561
)
561562

562-
app.DaoKeeper = daokeeper.NewBaseKeeper(
563-
appCodec, keys[daotypes.StoreKey], app.AccountKeeper, app.BankKeeper, authAddr,
563+
app.DaoKeeper = ucdaokeeper.NewBaseKeeper(
564+
appCodec, keys[ucdaotypes.StoreKey], app.AccountKeeper, app.BankKeeper, authAddr,
564565
)
565566

566567
epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey])
@@ -711,7 +712,7 @@ func NewHaqq(
711712

712713
// Haqq app modules
713714
coinomics.NewAppModule(app.CoinomicsKeeper, app.AccountKeeper, app.StakingKeeper),
714-
dao.NewAppModule(appCodec, app.DaoKeeper, app.GetSubspace(daotypes.ModuleName)),
715+
ucdao.NewAppModule(appCodec, app.DaoKeeper, app.GetSubspace(ucdaotypes.ModuleName)),
715716
)
716717

717718
// During begin block slashing happens after distr.BeginBlocker so that
@@ -749,7 +750,7 @@ func NewHaqq(
749750
coinomicstypes.ModuleName,
750751
consensusparamtypes.ModuleName,
751752
liquidvestingtypes.ModuleName,
752-
daotypes.ModuleName,
753+
ucdaotypes.ModuleName,
753754
)
754755

755756
// NOTE: fee market module must go last in order to retrieve the block gas used.
@@ -786,7 +787,7 @@ func NewHaqq(
786787
coinomicstypes.ModuleName,
787788
consensusparamtypes.ModuleName,
788789
liquidvestingtypes.ModuleName,
789-
daotypes.ModuleName,
790+
ucdaotypes.ModuleName,
790791
)
791792

792793
// NOTE: The genutils module must occur after staking so that pools are
@@ -826,7 +827,7 @@ func NewHaqq(
826827
coinomicstypes.ModuleName,
827828
erc20types.ModuleName,
828829
epochstypes.ModuleName,
829-
daotypes.ModuleName,
830+
ucdaotypes.ModuleName,
830831
// NOTE: crisis module must go at the end to check for invariants on each module
831832
crisistypes.ModuleName,
832833
consensusparamtypes.ModuleName,
@@ -1189,7 +1190,7 @@ func initParamsKeeper(
11891190
// haqq subspaces
11901191
paramsKeeper.Subspace(coinomicstypes.ModuleName)
11911192
paramsKeeper.Subspace(liquidvestingtypes.ModuleName)
1192-
paramsKeeper.Subspace(daotypes.ModuleName)
1193+
paramsKeeper.Subspace(ucdaotypes.ModuleName)
11931194

11941195
return paramsKeeper
11951196
}
@@ -1298,6 +1299,12 @@ func (app *Haqq) setupUpgradeHandlers() {
12981299
v176.CreateUpgradeHandler(app.mm, app.configurator, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.DaoKeeper, app.LiquidVestingKeeper, app.Erc20Keeper),
12991300
)
13001301

1302+
// v1.7.7 Rename DAO module to United Contributors DAO
1303+
app.UpgradeKeeper.SetUpgradeHandler(
1304+
v177.UpgradeName,
1305+
v177.CreateUpgradeHandler(app.mm, app.configurator),
1306+
)
1307+
13011308
// When a planned update height is reached, the old binary will panic
13021309
// writing on disk the height and name of the update that triggered it
13031310
// This will read that value, and execute the preparations for the upgrade.
@@ -1341,7 +1348,16 @@ func (app *Haqq) setupUpgradeHandlers() {
13411348
case v176.UpgradeName:
13421349
storeUpgrades = &storetypes.StoreUpgrades{
13431350
Added: []string{
1344-
daotypes.ModuleName,
1351+
ucdaotypes.ModuleOldName,
1352+
},
1353+
}
1354+
case v177.UpgradeName:
1355+
storeUpgrades = &storetypes.StoreUpgrades{
1356+
Renamed: []storetypes.StoreRename{
1357+
{
1358+
OldKey: ucdaotypes.ModuleOldName,
1359+
NewKey: ucdaotypes.ModuleName,
1360+
},
13451361
},
13461362
}
13471363
}

app/upgrades/v1.7.6/handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import (
1818
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
1919
"github.com/ethereum/go-ethereum/common"
2020

21-
daokeeepr "github.com/haqq-network/haqq/x/dao/keeper"
2221
erc20keeper "github.com/haqq-network/haqq/x/erc20/keeper"
2322
erc20types "github.com/haqq-network/haqq/x/erc20/types"
2423
liquidvestingkeeper "github.com/haqq-network/haqq/x/liquidvesting/keeper"
2524
liquidvestingtypes "github.com/haqq-network/haqq/x/liquidvesting/types"
25+
daokeeepr "github.com/haqq-network/haqq/x/ucdao/keeper"
2626
vestingtypes "github.com/haqq-network/haqq/x/vesting/types"
2727
)
2828

app/upgrades/v1.7.6/upgrades.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
1111
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
1212

13-
daokeeper "github.com/haqq-network/haqq/x/dao/keeper"
1413
erc20keeper "github.com/haqq-network/haqq/x/erc20/keeper"
1514
liquidvestingkeeper "github.com/haqq-network/haqq/x/liquidvesting/keeper"
15+
daokeeper "github.com/haqq-network/haqq/x/ucdao/keeper"
1616
)
1717

1818
// CreateUpgradeHandler creates an SDK upgrade handler for v1.7.6

app/upgrades/v1.7.7/constants.go

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package v177
2+
3+
const (
4+
// UpgradeName is the shared upgrade plan name for mainnet and testnet
5+
UpgradeName = "v1.7.7"
6+
)

app/upgrades/v1.7.7/upgrades.go

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package v177
2+
3+
import (
4+
sdk "github.com/cosmos/cosmos-sdk/types"
5+
"github.com/cosmos/cosmos-sdk/types/module"
6+
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
7+
)
8+
9+
// CreateUpgradeHandler creates an SDK upgrade handler for v1.7.7
10+
func CreateUpgradeHandler(
11+
mm *module.Manager,
12+
configurator module.Configurator,
13+
) upgradetypes.UpgradeHandler {
14+
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
15+
logger := ctx.Logger()
16+
logger.Info("run migration v1.7.7")
17+
18+
return mm.RunMigrations(ctx, configurator, vm)
19+
}
20+
}

proto/haqq/dao/module/v1/module.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "cosmos/app/v1alpha1/module.proto";
77
// Module is the config object of the distribution module.
88
message Module {
99
option (cosmos.app.v1alpha1.module) = {
10-
go_import: "github.com/haqq-network/haqq/x/dao"
10+
go_import: "github.com/haqq-network/haqq/x/ucdao"
1111
};
1212

1313
// max_metadata_len defines the maximum proposal metadata length.

proto/haqq/dao/v1/dao.proto

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ package haqq.dao.v1;
55
import "gogoproto/gogo.proto";
66
import "amino/amino.proto";
77

8-
option go_package = "github.com/haqq-network/haqq/x/dao/types";
8+
option go_package = "github.com/haqq-network/haqq/x/ucdao/types";
99

1010
// Params defines the parameters for the dao module.
1111
message Params {
12-
option(amino.name) = "haqq/x/dao/Params";
12+
option(amino.name) = "haqq/x/ucdao/Params";
1313
option(gogoproto.goproto_stringer) = false;
1414
// enable_dao is the parameter to enable the module functionality.
1515
bool enable_dao = 1;
@@ -31,7 +31,7 @@ enum CollateralValueType {
3131
}
3232

3333
message AllowedCollateral {
34-
option(amino.name) = "haqq/x/dao/AllowedCollateral";
34+
option(amino.name) = "haqq/x/ucdao/AllowedCollateral";
3535
option(gogoproto.goproto_stringer) = false;
3636

3737
// value is the allowed collateral value.

proto/haqq/dao/v1/genesis.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import "cosmos_proto/cosmos.proto";
88
import "amino/amino.proto";
99
import "haqq/dao/v1/dao.proto";
1010

11-
option go_package = "github.com/haqq-network/haqq/x/dao/types";
11+
option go_package = "github.com/haqq-network/haqq/x/ucdao/types";
1212

1313
// GenesisState defines the gov module's genesis state.
1414
message GenesisState {

proto/haqq/dao/v1/query.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import "cosmos/query/v1/query.proto";
1111
import "amino/amino.proto";
1212
import "haqq/dao/v1/dao.proto";
1313

14-
option go_package = "github.com/haqq-network/haqq/x/dao/types";
14+
option go_package = "github.com/haqq-network/haqq/x/ucdao/types";
1515

1616
// Query defines the gRPC querier service for dao module
1717
service Query {

proto/haqq/dao/v1/tx.proto

+22-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ import "cosmos_proto/cosmos.proto";
88
import "cosmos/msg/v1/msg.proto";
99
import "amino/amino.proto";
1010

11-
option go_package = "github.com/haqq-network/haqq/x/dao/types";
11+
option go_package = "github.com/haqq-network/haqq/x/ucdao/types";
1212

1313
// Msg defines the dao Msg service.
1414
service Msg {
1515
option (cosmos.msg.v1.service) = true;
1616

1717
// Fund defines a method to allow an account to directly fund the dao.
1818
rpc Fund(MsgFund) returns (MsgFundResponse);
19+
20+
// TransferOwnership defines a method to allow an account to transfer the ownership of shares to another account.
21+
rpc TransferOwnership(MsgTransferOwnership) returns (MsgTransferOwnershipResponse);
1922
}
2023

2124
// MsgFund allows an account to directly fund the dao.
@@ -36,3 +39,21 @@ message MsgFund {
3639

3740
// MsgFundResponse defines the Msg/Fund response type.
3841
message MsgFundResponse {}
42+
43+
// MsgTransferOwnership allows an account transfer the ownership of shares to another account.
44+
message MsgTransferOwnership {
45+
option (cosmos.msg.v1.signer) = "owner";
46+
option (amino.name) = "haqq/dao/MsgTransferOwnership";
47+
48+
option (gogoproto.equal) = false;
49+
option (gogoproto.goproto_getters) = false;
50+
51+
// owner is a current owner of the shares in dao.
52+
string owner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
53+
54+
// new_owner is a new owner of the shares in dao.
55+
string new_owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
56+
}
57+
58+
// MsgTransferOwnershipResponse defines the Msg/TransferOwnership response type.
59+
message MsgTransferOwnershipResponse {}

0 commit comments

Comments
 (0)